Merge remote-tracking branch 'BenLubar/repeat-util-cancel-self' into develop

develop
lethosor 2017-07-12 16:35:24 -04:00
commit d236181cdc
1 changed files with 7 additions and 2 deletions

@ -17,7 +17,9 @@ function cancel(name)
if not repeating[name] then
return false
end
dfhack.timeout_active(repeating[name],nil)
if repeating[name] ~= -1 then
dfhack.timeout_active(repeating[name],nil)
end
repeating[name] = nil
return true
end
@ -26,8 +28,11 @@ function scheduleEvery(name,time,timeUnits,func)
cancel(name)
local function helper()
func()
repeating[name] = dfhack.timeout(time,timeUnits,helper)
if repeating[name] then
repeating[name] = dfhack.timeout(time,timeUnits,helper)
end
end
repeating[name] = -1
helper()
end