I can only get the event trigger to work. So i can't tell which timer triggered the event.
I also referenced the example under the Timer(event) page on the CC wiki. if i copy and past there code (shown below) it works great with 2 timers.
But if i try it with my code it fails.
As far as i can see the complete parameter somehow never matches the timer name (timerA or timerB).
I also cannot find much info on how it works or and detailed wiki pages.
Timer(event) page
local timerA = os.startTimer(1) local timerB = os.startTimer(2) while true do local event, completed = os.pullEvent() if event == "timer" then if completed == timerA then print("TimerA has finished, restarting it now") timerA = os.startTimer(1) elseif completed == timerB then print("TimerB has finished, restarting it now") timerB = os.startTimer(2) else print("A timer finished, but it wasn't one of the ones I care about") end end end
My Test Code
function TimeA() local timerA=os.startTimer(3) end function TimeB() local timerB=os.startTimer(5) end TimeA() TimeB() while true do local event,complete=os.pullEvent() if event == "timer" then print("Timer Triggered") if complete == timerA then print("time A triggered") TimeA() end if complete == timerB then print("time B triggered") TimeB() end end if event=="char" and complete=="x" then break end end