Version: stable
FUNCTION | |
---|---|
timer.delay() | create a timer |
timer.cancel() | cancel a timer |
timer.trigger() | trigger a callback |
timer.get_info() | get information about timer |
CONSTANT | |
---|---|
timer.INVALID_TIMER_HANDLE | Indicates an invalid timer handle |
timer.delay(delay,repeat,callback)
Adds a timer and returns a unique handle You may create more timers from inside a timer callback. Using a delay of 0 will result in a timer that triggers at the next frame just before script update functions. If you want a timer that triggers on each frame, set delay to 0.0f and repeat to true. Timers created within a script will automatically die when the script is deleted.
PARAMETERS
delay |
number |
time interval in seconds |
repeat |
boolean |
true = repeat timer until cancel, false = one-shot timer |
callback |
function(self, handle, time_elapsed) |
timer callback function
|
RETURNS
|
hash | handle identifier for the create timer, returns timer.INVALID_TIMER_HANDLE if the timer can not be created |
timer.cancel(handle)
You may cancel a timer from inside a timer callback. Cancelling a timer that is already executed or cancelled is safe.
PARAMETERS
handle |
hash |
the timer handle returned by timer.delay() |
RETURNS
true |
boolean | if the timer was active, false if the timer is already cancelled / complete |
timer.trigger(handle)
Manual triggering a callback for a timer.
PARAMETERS
handle |
hash |
the timer handle returned by timer.delay() |
RETURNS
true |
boolean | if the timer was active, false if the timer is already cancelled / complete |
timer.get_info(handle)
Get information about timer.
PARAMETERS
handle |
hash |
the timer handle returned by timer.delay() |
RETURNS
data |
table | or nil if timer is cancelled/completed. table with data in the following fields:
|
Indicates an invalid timer handle