I can’t seem to figure this one out. I’m trying to figure out how to reset the numTaps to 0 when I want it to. I have some functions that run on numTaps 1 and 2. but sometimes I want it to reset the number of taps so that you cant trigger the numTaps = 2 requirement. I was hoping a simple return true would work but it doesn’t. Any help is greatly appreciated, thank you in advance. [import]uid: 77199 topic_id: 34197 reply_id: 334197[/import]
Can you not just test for the condition where you want it to reset and then do:
numTaps=0
I’m not exactly sure in what circumstances you want to not trigger numTaps = 2.
[import]uid: 84115 topic_id: 34197 reply_id: 136016[/import]
Is this from an event “tap” handler? [import]uid: 199310 topic_id: 34197 reply_id: 136076[/import]
Yeah it is from an event “tap” handler. and no numTaps = 0 didn’t work unfortunately, or at least I’m pretty sure it didn’t. I’ll check again tonight but pretty sure it didn’t. [import]uid: 77199 topic_id: 34197 reply_id: 136226[/import]
While you can certainly change the value of numTaps while inside that event handler, once the handler function returns, those values are lost and the next trigger of the event will have a fresh event table with an all new tap count.
You really should consider things coming in from any event trigger a read-only value. [import]uid: 199310 topic_id: 34197 reply_id: 136233[/import]
I just tried this
function whatever( event )
if event.numTaps == 1 then
numTaps = 0
return true
elseif event.numTaps == 2 then
print( "asdfa" )
end
end
and the print goes through. Am I not understanding something [import]uid: 77199 topic_id: 34197 reply_id: 136246[/import]
Can you not just test for the condition where you want it to reset and then do:
numTaps=0
I’m not exactly sure in what circumstances you want to not trigger numTaps = 2.
[import]uid: 84115 topic_id: 34197 reply_id: 136016[/import]
Is this from an event “tap” handler? [import]uid: 199310 topic_id: 34197 reply_id: 136076[/import]
Yeah it is from an event “tap” handler. and no numTaps = 0 didn’t work unfortunately, or at least I’m pretty sure it didn’t. I’ll check again tonight but pretty sure it didn’t. [import]uid: 77199 topic_id: 34197 reply_id: 136226[/import]
While you can certainly change the value of numTaps while inside that event handler, once the handler function returns, those values are lost and the next trigger of the event will have a fresh event table with an all new tap count.
You really should consider things coming in from any event trigger a read-only value. [import]uid: 199310 topic_id: 34197 reply_id: 136233[/import]
I just tried this
function whatever( event )
if event.numTaps == 1 then
numTaps = 0
return true
elseif event.numTaps == 2 then
print( "asdfa" )
end
end
and the print goes through. Am I not understanding something [import]uid: 77199 topic_id: 34197 reply_id: 136246[/import]