How to deactivate the keyboard via LUA

  • #1, by marvelSaturday, 31. January 2015, 13:36 6 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

    598 Posts


  • #2, by afrlmeSaturday, 31. January 2015, 14:34 6 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")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10


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

    Imperator

    6816 Posts

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

    Key Killer

    598 Posts

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

    Imperator

    6816 Posts

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

    Key Killer

    598 Posts

  • #6, by afrlmeSunday, 01. February 2015, 15:46 6 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

    6816 Posts

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

    Key Killer

    598 Posts

Write post