Skip to content

LuaAPI Timers

itvnnnd87 edited this page Oct 24, 2026 · 3 revisions

Timers

Time events

In System\Timers.lua:

Function Called when
onTimerProcessSecond() Every second.
onTimerProcessMinute() When a new minute starts.
onTimerProcessHour() When a new hour starts.
onTimerProcessDayChange() When a new day starts (00:00).

Script timers

Unit: seconds. Creating a timer with an existing name replaces the old one. An error in one timer does not affect the others. Timers are cleared when LuaAPI is reloaded.

Function Description
Timer.Create(seconds, name, function() ... end) Runs once after seconds.
Timer.CreateRepeating(seconds, name, function() ... end) Repeats every seconds.
Timer.RepeatNTimes(seconds, name, times, function(n) ... end) Repeats times times, n = 1..times.
Timer.Remove(name) Removes the timer.
Timer.Exists(name) true if the timer still exists.
Timer.GetRemaining(name) Seconds left.
Timer.Stop(name) Pauses the timer (it keeps its remaining time).
Timer.Start(name) Resumes a paused timer.
Timer.IsActive(name) true if the timer exists and is not paused.

Daily / weekly events from an XML schedule: see Scheduler.

-- 10 second countdown
Timer.RepeatNTimes(1, "Countdown", 10, function(n)
    Message.SendAll(0, "The event starts in " .. (11 - n) .. " seconds")
end)

Next: Safety and languages

Clone this wiki locally