OnTick
Every simulation tick, with the time since the last one.
Thirty times a second ([rates] tick_hz), after the tick’s network events were applied. Whatever runs here runs for every
tick of every player’s game, so keep it to a few lines; do the heavy things on a timer every
second instead. The server log reports the slowest tick while the budget is missed.
Syntax
Section titled “Syntax”function OnTick(dt) -- ...end| Parameter | Type | |
|---|---|---|
dt |
number | seconds since the previous tick (0.033 at 30 Hz) |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”local elapsed = 0
function OnTick(dt) elapsed = elapsed + dt if elapsed >= 1 then -- once a second is enough for most bookkeeping elapsed = 0 checkRound() endendSee also
Section titled “See also”SetTimer · GetServerTick · the Server and timers group of the index
