@David (if you pick this up)
I'm trying to manage semaphore 'errors' and wonder if it's possible to 'switch off' the event.keypress completely within a script, at specific times.
In other words, if block A of my script is running then event.keypress is working, but for block B of my script it is not, ie it is as if it wasn't there.
And, in the script, switch event.keypress back on as well ;)
UPDATE
Ok I can switch it off with
event.keypress = nil
But how do I switch it back on again?
UPDATE
OK I worked it out. As above to switch it off, simple redefine it to switch it back on. At the moment I redefine it by restating the entire function. Is there a way to get event.keypress to call one of my functions?
UPDATE:2
OK, I know I'm dumb >:(
It's as simple as this:
event.keypress = function(key)
return mykey_test(key)
end
BTW
If others are interested in why I was pursuing this line, around event.keypress, it was because I wanted to change the functionality of buttons according to the state of the script.
Using the above approach, it looks very simple (and safe?) to switch the event.keypress on and off, and change what it does according to where one is in a script.
Unless I've got it wrong that is ;D
Cheers
Garry
You can make it even simpler:
event.keypress = mykey_test
@David
Thanks: I'll give that a try :)
Cheers
Garry
@David
Tried it out and it worked a charm. I can now turn the event.keypress on and off when I need it and change its behaviour according to the script's needs.
Once again, thanks for your 'coaching'; relative to where I was last year, thanks to you and others, I now feel confident in my Lua scripting...other than output to file stuff, eg saving my settings etc. That's my next education focus ;)
Cheers
Garry