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).
reskate.time.after(ms, fn)
Runs fn once, ms milliseconds from now.
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.
reskate.time.cancel(id)
Stops a timer. A timer that has already run once (after), or was cancelled already, is ignored.
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 is timed like any handler: a warning past 50 ms, stopped past 1000 ms. 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, soreskate.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.
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.
Needs the
game.speed permission.