Hi!
I’m doing a timed laser that will swith on and off.
The thing is I don’t know how to stop this timer.
Here’s the code :
[lua]laser.timer = function(isActive)
local stop
local tOff = timerOff
local tOn = timerOn
local clock
if isActive == true then
local on
local off
function on(e)
timer.cancel(e.source)
e.source = nil
laser.switchOn()
clock = timer.performWithDelay( tOn, off )
end
function off(e)
timer.cancel(e.source)
e.source = nil
laser.switchOff()
clock = timer.performWithDelay( tOff, on )
end
clock = timer.performWithDelay( 1, on )
else
timer.cancel( clock )
clock = nil
end
end[/lua]
I’m sending a boolean value to active the switching. But when sending FALSE, console says “Whoops, that timer doesn’t exist!”
Thanks [import]uid: 25327 topic_id: 18262 reply_id: 318262[/import]