Vital.sandbox
Timer

timer:create

Shared

Creates a new timer instance


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
Refer Callback section

Returns

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

Callback: exec

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

Examples

Create a timer that prints a message every second 5 times
local self = timer:create(function(message)
    engine.print("info", message)
end, 1000, 5, "Hello from timer")

On this page