Skip to content

Timers and time

Run code later or on a beat. Game seconds: timers pause with the game.

server + client

Calls fn() once, after seconds of game time. Server timers step about every 0.2 s; client timers run each frame, in a match only.

Parameter Type
seconds number 0.05 to 86400.
fn function No arguments.

Returns a timer handle (a number)

Raises

  • seconds must be 0.05 to 86400
  • callback must be a function
mod.after(10, function()
mod.game.toast("TEN SECONDS IN")
end)

server + client

Calls fn() every seconds of game time. A timer has no time limit; keep it short. One that errors 5 times stops.

Parameter Type
seconds number 0.05 to 86400.
fn function No arguments.

Returns a timer handle (a number)

Raises

  • seconds must be 0.05 to 86400
  • callback must be a function
local minutes = 0
mod.every(60, function()
minutes += 1
end)

server + client

Stops a timer.

Parameter Type
timer number What mod.after or mod.every returned.
local t = mod.every(1, function() end)
mod.cancel(t)

server + client

Seconds on the game clock. Not the date, and not for timing code.

Returns number

mod.log("clock:", mod.time())