Skip to main content
Version: 9.0.2

gre.timer_set_interval

gre.timer_set_interval(
callback,
interval
)

This function creates a repeating timer which fires every "interval" milliseconds and then executes "function"

Parameters

ParameterTypeDescription
callback#functionThe function to be called when the timer fires interval The time in milliseconds of how often the timer should fire

Returns

TypeDescription
#userdataA piece of lightuserdata which serves as an identifier for the timer.

Example

local idval = {}
function cb_func()
print("CB FUNC HAS BEEN CALLED")
end

--Call cb_func every 2 seconds
function cb_set_interval()
idval = gre.timer_set_interval(cb_func, 2000)
end