Skip to content

sdk.schedule ​

Timers on game.on("tick"). after / every are non-blocking. wait(ms) yields only when the caller is a coroutine.

lua
local M = require("sdk.schedule")

now ​

function · now(): number

Host clock via game.log.now_ms, or 0. Same 0 convention as cavebot traces. after/every stamp due times with this.

Returns

TypeSummary
number—

pump ​

function · pump(now)

Run due jobs; periodic jobs reschedule, one-shots drop. Stable order: due time, then id. pcall so one callback cannot starve the rest.

after ​

function · after(delay_ms: number, callback: fun()): TimerId?, ErrorMessage?

One-shot callback after ms (non-blocking). ms is clamped to >= 0. Use wait() only from a coroutine.

Parameters

NameTypeSummary
delay_msnumber—
callbackfun()—

Returns

TypeSummary
TimerId?, ErrorMessage?—

every ​

function · every(interval_ms: number, callback: fun()): TimerId?, ErrorMessage?

Repeating callback every ms (non-blocking). Period is at least 1 ms. cancel(id) to stop.

Parameters

NameTypeSummary
interval_msnumber—
callbackfun()—

Returns

TypeSummary
TimerId?, ErrorMessage?—

cancel ​

function · cancel(id: TimerId): Result?, ErrorMessage?

Drop a job by id. Unknown id is nil, 'unknown'. Safe to call twice.

Parameters

NameTypeSummary
idTimerId—

Returns

TypeSummary
Result?, ErrorMessage?—

reset ​

function · reset()

Drop every job (session end / tests). Does not unhook tick; ensure() stays latched. In-flight wait() coroutines will hang if not resumed.

wait ​

function · wait(ms)

Suspend the current coroutine for at least ms without blocking the game thread. Calling this from a normal top-level script is an API error; use after there.

Parameters

NameTypeSummary
msnumber—

Returns

TypeSummary
boolean|nilok
string|nilerr

Arcane SDK catalog generated from scripts/sdk