Maybe someone can guide with this: I'm trying to have a call to a function when the current time hits 10 seconds, 20 seconds, 30 etc.
For that I used the Lua code:
if elapsed seconds == 10 then
call-to-the-function
end
Problem is that this part is not working well as I missing something (type of variable conversion?) as the condition seems to be true for values between 10, 10.1 , 10.2, 10.3, 10.n milliseconds or at least until it reach 11
Yes, I think so, thanks for the help both of you guys, I'll check it out and back to report! Btw do you know any good code example about delays and reset triggers beyond the ones in the documentation, I'm struggling a little bit with that as well.
Tnx!
Sadly I'm afraid is not working. Very curious...
The idea is simply: have a time counter and trigger an action each several seconds or minutes, but for some reason the comparison between the timer and a integer number using ==
does not work as expected.
Is there any other way to do this with a delay timer?
Tnx!
FWIW I had a lot of timed delays like that in my Playtime clock app, and I ended up handling them by setting a timer—and then setting it again and again.
(But I didn't set it for, say, "10 seconds" every time—I checked the time, calculated the "next 10 second mark" and then set the timer for less if drawing delay etc. had already taken up time. Otherwise, the delay would eventually drift. Plus, the very FIRST timer would be wrong without that current-time check.)
Thank you so much, all of you!
A lot of good information and examples. Apparently it was not a minor subject as I though.
I will take a deep look to the code above (much appreciated!) and try to implement a solution from it.