[BUG] Timer:setTimerInterval(interval) is buggy! [SOLVED]
Posted: Sat Dec 08, 2012 3:32 am
I had some problems with this today, so I did a test map
just first empty room:
one script "countScript"
one timer "countTimer"
one button to start things, linked to activate timer, that's all
timer linked to script with "activate" -> "display"
script:
When I push the button the timer starts with it's default 1s time, then I see TICK TOCK in the console with the random number.
BUT THE NUMBER IS WRONG!
Sometimes it's right, but just watch a stopwatch or listen to a clock ticking in your computer room, and almost always the next TICK TOCK message is NOT after the right amount of time. Sometimes it seems to fire off almost two in a row immediately, other times it seems to take twice as long as it should, so 4 seconds become 8, or anywhere in-between
(although usually it seems to be an integer at least, the firing seems to always be on-the-second and not a fraction)
It's totally unreliable!
just first empty room:
one script "countScript"
one timer "countTimer"
one button to start things, linked to activate timer, that's all
timer linked to script with "activate" -> "display"
script:
Code: Select all
function countTimerSet()
local delay = math.random(3,6)
countTimer:setTimerInterval(delay)
print("timer set to "..delay)
end
function display()
print("TICK TOCK!")
countTimerSet()
endBUT THE NUMBER IS WRONG!
Sometimes it's right, but just watch a stopwatch or listen to a clock ticking in your computer room, and almost always the next TICK TOCK message is NOT after the right amount of time. Sometimes it seems to fire off almost two in a row immediately, other times it seems to take twice as long as it should, so 4 seconds become 8, or anywhere in-between
(although usually it seems to be an integer at least, the firing seems to always be on-the-second and not a fraction)
It's totally unreliable!