jmp909
November 19, 2010, 4:06pm
1
it would be useful to have an event that fires when all iterations of a timer are complete
(combined with my other request for the timer to start immediately this could be
[lua]timer.performWithDelay(1000, doSomething, 100, {onComplete=finishSomething, immediate=true})[/lua]
presumably this wouldnt break old code either, as the first 3 parameters are the same
thanks
j.
[import]uid: 6645 topic_id: 3809 reply_id: 303809[/import]
jmp909
November 20, 2010, 7:55am
2
note i did actually find a fix to fire the first call immediately
[import]uid: 6645 topic_id: 3809 reply_id: 11623[/import]
I’m looking for something like an onComplete for a timer, too. Would be very nice to have such a feature.
What are the other options to implement a similar functionality with the given Lua functions? I guess i would do it like this right now:
[lua]local counter = 100
local function listener( event )
print( “Doing some stuff here” )
counter = counter - 1
end
timer.performWithDelay(1000, listener, counter)
while counter >= 0 do
print (“Waiting for timer to finish”)
end
print(“Proceeding in code”)[/lua] [import]uid: 24216 topic_id: 3809 reply_id: 19473[/import]
jmp909
January 29, 2011, 3:13pm
4
your concept is right but you’ve implemented it wrong… that while loop wouldnt work there
anyway listener has event.count (it’s in the documentation) so you can check that in the listener itself to determine if the timer is complete [import]uid: 6645 topic_id: 3809 reply_id: 19479[/import]