Timer

Timer:setTimeout()

Description

To schedule execution of a one-time callback after delay milliseconds.

Syntax

timer:setTimeout(callback, delay)

Parameters

callback: function to execute after delay milliseconds
delay: time in milliseconds

Returns

nil

Example

timer=Timer:new()
timer:setTimeout(function()
–Your work that needs to execute 500ms later
end, 500)

See also

– Timer:setInterval()


Timer:setInterval()

Description

To schedule the repeated execution of callback every delay milliseconds.

Syntax

timer:setInterval(callback, delay)

Parameters

callback: function to execute after delay milliseconds
delay: time in milliseconds

Returns

nil

Example

timer=Timer:new()
timer:setInterval(function()
–Do your periodic work here
end, 500)

See also

– Timer:setTimeout()