Skip to main content
reskate.time reads a steady clock, runs functions later, and slows the game down. The clock and the timers need no permission; slow motion needs game.speed. Timers run in the game tick in which they fall due, just before the tick handlers. A timer is only as precise as the tick: a timer of 1 ms runs once a tick.

reskate.time.now()

The time in milliseconds on a steady clock. It only goes forward, and it does not follow the wall clock: use it to measure how long something took, not to tell the date (os.time and os.date do that).
number
Milliseconds, with fractions. Only differences between two readings mean anything.

reskate.time.after(ms, fn)

Runs fn once, ms milliseconds from now.
number
required
0 or more. 0 runs it at the next tick.
function
required
Called with no arguments.
integer
The timer’s id, for reskate.time.cancel.

reskate.time.every(ms, fn)

Runs fn every ms milliseconds until you cancel it. Each next run is ms after the tick in which the last one ran.
number
required
1 or more.
function
required
Called with no arguments.
integer
The timer’s id, for reskate.time.cancel.

reskate.time.cancel(id)

Stops a timer. A timer that has already run once (after), or was cancelled already, is ignored.
integer
required
What after or every returned.
A wrong argument raises an error: a negative or non-finite ms for after, less than 1 for every, or a fn that is not a function. A plugin has at most 1024 timers waiting; the next one raises an error. Each timer call has 50 ms, like any handler. See limits.

Slow motion

The game runs slower while any plugin asks for it: the slowest ask runs. It stays smooth: the game takes as many physics steps each real second as before, each the shorter. The clock and the timers above keep real time throughout, so reskate.time.after(1000, fn) still runs a second later. Slow motion never runs in a multiplayer session, where your game must keep the other players’ pace: asking in one is refused, and a session that starts while it runs ends it.

reskate.time.slow(speed)

Asks for the game to run at speed.
number
default:"1"
0.05 to 1, of the game’s own speed. 1 (or nothing) drops your ask.
boolean
True when the ask was taken.
string
"never in a multiplayer session" when ok is false.
A speed outside 0.05 to 1 raises an error.
Needs the game.speed permission. A taken ask does not always slow the game: not when it already runs as slowly (the trainer’s practice speed, for one), without a local skater, or once the game’s speed is changed from elsewhere (the trainer, the console) during this slow motion. reskate.time.speed() says what runs. When the plugin stops, its ask is dropped.

reskate.time.speed()

The speed the game runs at for plugins now.
number
The slowest plugin’s ask while slow motion runs, else 1.
Needs the game.speed permission.