rune.timer
Timers run actions after a delay or at a fixed interval. For a task-oriented introduction, see Timers.
Quick reference
Section titled “Quick reference”rune.timer.after(seconds, action, opts?) -- one-shot: fires once, then removes itselfrune.timer.every(seconds, action, opts?) -- repeating: fires every intervalrune.timer.cancel(name) -- alias of rune.timer.removeBoth constructors return a handle and accept
the common options (name, group). Timer
handles additionally accept h:cancel() as an alias of h:remove().
rune.timer.every
Section titled “rune.timer.every”rune.timer.every(seconds, action, opts?) -> handleseconds(number) — the interval, in seconds (fractions allowed).action(string | function) — a command string sent on each firing, orfunction(ctx).opts(table, optional) — common options.
Scheduling is fixed-interval: the next firing is scheduled the moment the previous one fires, regardless of how long the action takes to run.
rune.timer.every(60, "save", {name = "autosave"})Actions and self-cancellation
Section titled “Actions and self-cancellation”A string action is sent as a command. A function action receives a
context table (ctx.name, ctx.group, ctx.type); ctx:remove() is
how a repeating timer stops itself:
local ticks = 0rune.timer.every(10, function(ctx) ticks = ticks + 1 rune.send("look") if ticks >= 5 then ctx:remove() endend)Pausing and resuming
Section titled “Pausing and resuming”h:disable() suppresses firing without unregistering; h:enable()
resumes. A repeating timer keeps its schedule while disabled and picks
it back up on re-enable.
Managing
Section titled “Managing”Standard registry management applies:
rune.timer.enable/disable/remove(name), .cancel(name), .list(),
.count(), .clear(), .remove_group(group) — see
Registries. /timers lists everything.
Related: Timers guide · rune.trigger · rune.hooks · rune.group