How to deactivate the keyboard via LUA

  • #1, by marvelSaturday, 31. January 2015, 13:36 10 years ago
    I have several key controls in my game. ESC opens a Menu, F5 the Save Games, F8 the Soundcontrol... and so on.

    Now I want to "block" all those keys while I'm in a specific menu by deactivating the keyboard in general. How to do so? smile

    Key Killer

    599 Posts


  • #2, by afrlmeSaturday, 31. January 2015, 14:34 10 years ago
    This is completely untested on my part. Just a theoretical script.

    You need to create a condition somewhere. Call it: "keyboard_active" & set to true

    Now add this to the script section.
    function keyboardHandler(eventType, character, keycode, modifiers)
     if not Conditions["keyboard_active"].ConditionValue then
      return true
     else
      return false
     end
    end
     
    registerEventHandler("keyEvent", "keyboardHandler")
    


    To toggle keyboard on / off just change the condition value.

    Imperator

    7285 Posts

  • #3, by marvelSunday, 01. February 2015, 12:59 10 years ago
    Can you tell me what you mean by "Change the condition value"? smile

    Key Killer

    599 Posts

  • #4, by afrlmeSunday, 01. February 2015, 13:55 10 years ago
    By changing the condition I mentioned in step 1 to true or false? What else.... razz

    Imperator

    7285 Posts

  • #5, by marvelSunday, 01. February 2015, 15:32 10 years ago
    Ah, ok... so i need to change the value of the condition. ^^ "Condition value" was irritating.

    Key Killer

    599 Posts

  • #6, by afrlmeSunday, 01. February 2015, 15:46 10 years ago
    Same bloody thing! razz

    I suppose I could have said: "change the value of the condition" or I could have even said: "change the conditions value" or I could have said, what I already said. wink

    You say potato & I say patato!

    Imperator

    7285 Posts

  • #7, by marvelSunday, 01. February 2015, 23:36 10 years ago
    It works like a charm now. Thanks Lee. smile

    Key Killer

    599 Posts