Skip to content

timer

start

start()

Starts the timer.

Usage

local timer = utils.new_timer(100, function()
    print('This will be printed every 100ms');
end);

timer:start();

stop

stop()

Stops and resets the timer.

Usage

timer:stop();

run_once

run_once()

Runs a timer only once, after the previously specified delay.

Usage

local timer = utils.new_timer(100, function()
    print('This will be printed once after 100ms');
end);

timer:run_once();

is_active

is_active() -> bool

Returns true if the timer is currently active.

Usage

local timer_active = timer:is_active();

set_delay

set_delay(val: number)

Sets the delay of the timer.

Parameters

Name Type Description
val number Delay between timer calls, in ms

Usage

local timer = utils.new_timer(0, function()
    print('This will be run every 1000ms');
end);
timer:set_delay(1000);
timer:start();