Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

How to deactivate the keyboard via LUA

  • #1, by marvel 11 years ago Zitieren
    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
  • #2, by afrlme 11 years ago Zitieren
    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.
  • #3, by marvel 11 years ago Zitieren
    Can you tell me what you mean by "Change the condition value"? smile
  • #4, by afrlme 11 years ago Zitieren
    By changing the condition I mentioned in step 1 to true or false? What else.... razz
  • #5, by marvel 11 years ago Zitieren
    Ah, ok... so i need to change the value of the condition. ^^ "Condition value" was irritating.
  • #6, by afrlme 11 years ago Zitieren
    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!
  • #7, by marvel 11 years ago Zitieren
    It works like a charm now. Thanks Lee. smile