time between clickdown and clickup Thread last updated on 2007-12-19 20:44:54

Posted by member 106929 on 2007-12-16 09:59:56

hi,

how would one go about finding the time between a clickdown/up event in a label (preferably in ms)?

i've been trying to accomplish this with an evar (switching between 1/0 on down/up respectively) and a lua while loop (the condition being if the evar == 1), but the loop either doesn't want to start at the right time or it just loops forever. plus, even if i could get the loop working correctly, i have no idea what the time between loop repeats is (or where to find it), or even if the time between each repeat varies between computers.

thanks

Posted by member 256241 on 2007-12-16 13:35:53 link

Could use the timer module... Start the timer onclickdown, stop the timer onclick up, have it run every milisecond and add one to a value each time, onclickup export the value somehow.

I don't know about LUA very much, but it'd be easy with timer and mzscript.

Posted by member 106929 on 2007-12-16 17:09:55 link

wow that was so simple
thank you so much

Posted by member 256241 on 2007-12-16 22:14:10 link

No problem.

Obviously, for efficiency if accuracy is not deadly important, have it update every 5 ms and add 5... etc.

Posted by member 93947 on 2007-12-19 20:18:39 link

Oo just save the starttime
onbuttondown !luaexec starttime = os.time()
onbuttonup !luaexec thefunctionthatneedsthetime( os.time()-starttime )

Posted by member 106929 on 2007-12-19 20:44:54 link

haha.. i really need to read that lua documentation

thanks, thc