Vital.sandbox
Timer

timer:create

Shared

Creates a new timer context


Syntax

local ctx = timer:create(exec, interval, executions, ...)

Parameters

TypeNameDescription
functionexecFunction to be executed by the timer
intintervalExecution interval in milliseconds
intexecutionsTotal number of times the function will execute
......Additional arguments to pass to the exec callback

Returns

TypeNameDescription
timer / boolctxReturns timer instance on successful execution, or false on failure

Callback

exec(...)
TypeNameDescription
......Additional arguments

Examples

local self = timer:create(function(message)
    engine.print(message)
end, 1000, 5, "Hello from timer")

On this page