25.02.2020, 07:55
(24.02.2020, 12:50)Patrix Wrote:Thanks, buddy.demor140202 Wrote:I know how to configure the keys by clicking on which something will happen. But how do I cancel these settings? How do I make the key stop calling an action?
Hm.. that depends of your "needs".
If you only want a F7 key to stop working after pressing it, you can always write something like this:
Code:local freezeKeyPressed = false
addEventHandler("onKey", function(key)
{
switch (key)
{
case KEY_F7:
if (!freezeKeyEnabled)
{
setFreeze(true)
freezeKeyEnabled = true
}
break
}
})
In order to re-enable the F7 functionallity, change the content of the "freezeKeyEnabled" variable back to "false".
Also, maybe you don't want to "disable" the key, but rather after pressing it second time, call the setFreeze(false).
To do that, you can make something like this:
Code:local menuVisible = false // dummy variable for example purposes
addEventHandler("onKey", function(key)
{
switch (key)
{
case KEY_F7:
menuVisible = !menuVisible // negating a variable content
setFreeze(menuVisible)
break
}
}
Also, do note, that you can add more than one function to a specific event using addEventHandler function.