Restore periodicalEvent function

* and typo fixes
This commit is contained in:
Eduardo Bart
2012-07-10 14:36:18 -03:00
parent 351115d9d9
commit d39ca7de10
3 changed files with 21 additions and 2 deletions

View File

@@ -31,6 +31,25 @@ function cycleEvent(callback, front)
return event
end
function periodicalEvent(eventFunc, conditionFunc, delay, autoRepeatDelay)
delay = delay or 30
autoRepeatDelay = autoRepeatDelay or delay
local func
func = function()
if conditionFunc and not conditionFunc() then
func = nil
return
end
eventFunc()
scheduleEvent(func, delay)
end
scheduleEvent(function()
func()
end, autoRepeatDelay)
end
function removeEvent(event)
if event then
event:cancel()