The Timer class can be used to execute a function periodically.
Example to create a function that is called:
local timer = Timer{
interval=5.0,
ontick=function()
print('Each 5 seconds')
end }
timer:start()Or a function that is called just once after one second:
local timer
timer = Timer{
interval=1.0,
ontick=function()
print('Called')
timer:stop()
end }
timer:start()local timer = Timer{ interval=number,
ontick=function }Creates a new timer.
interval: Number of seconds to wait for the first/next call. You can specify decimal numbers, e.g.interval=1.0 / 60.0to call the function 60 times per second, etc.ontick: Function that is called each time the specified number of seconds ellapses.
Starts the timer.
Stops the timer.
Returns the interval of this specific timer (in seconds).
Returns true if the timer is running.