Timer

Tip

This is a global variable named Timer. It is not possible to initialize or create a new instance. It’s just a global variable.

Attention

This page is under construction.

Functions

Returns

Name

Description

number ID

SetTimeout(number Cooldown, table {Args…}, function Function)

Sets a Timeout which will call Function at every Cooldown milliseconds, returns false inside the function to stops it

ClearTimeout(number ID)

Clears/Cancel a Timeout given it’s ID

Examples

-- creates a Timeout to call a function at every 1 second
local my_id = Timer:SetTimeout(1000, {}, function()
    Package:Log("Tick 1 second!")
end)

-- cancels the timeout
Timer:ClearTimeout(my_id)

my_function = function(my_param)
    Package:Log("nanos " .. my_param)
    return false
end

-- creates a Timeout to call my_function in 5 seconds, once
local my_id = Timer:SetTimeout(5000, {"world"}, my_function)