Skip to content

Scripting Timer

Dreamy Cecil edited this page Oct 25, 2026 · 2 revisions

Constants

  • TickQuantum - Contains length of a single game tick in seconds. Equivalent to the engine's CTimer::TickQuantum constant.

Classes

Timer.Value

Class for holding timer values measured in CPU cycles.

Metamethods

Timer.Value(seconds = 0)

Constructs a timer value instance with the specified value in seconds. If left unspecified, defaults to 0 CPU cycles.

Arguments:

  • seconds (optional) - Amount of seconds to set to the timer value.

+ operator

Adds two timer values together.

Right-side operand: Timer.Value

Return value: Timer.Value


- operator

Subtracts another timer value from the first one.

Right-side operand: Timer.Value

Return value: Timer.Value


clone()

Creates a copy of the timer value instance.

Return value: Timer.Value


tostring()

Returns timer value in seconds formatted as %gs.

Return value: string

Variables

msec

Read-only variable of the current timer value in milliseconds. Equivalent to the engine's CTimerValue::GetMilliseconds() function.

Type Readable Writeable
integer Yes No

sec

Read-only variable of the current timer value in seconds. Equivalent to the engine's CTimerValue::GetSeconds() function.

Type Readable Writeable
float Yes No

Functions

Timer.GetRealTimeTick()

Consistent across the entire game. Equivalent to the engine's CTimer::GetRealTimeTick() function.

Return value: float with the current game time in seconds since the beginning.


Timer.CurrentTick()

Returns current game tick in seconds depending on context where it's called from, e.g. game menu processing, NETRICSA processing or world simulation processing. Affected by the speed of the current world. Equivalent to the engine's CTimer::CurrentTick() function.

Tip

If you need consistent current tick time of the world simulation regardless of context, use World.GetCurrentTick() instead.

Return value: float with the current game tick in seconds.


Timer.GetLerpedCurrentTick()

Returns current frame time in seconds depending on context where it's called from, e.g. game menu rendering, NETRICSA rendering or world rendering. Affected by the speed of the current world. Equivalent to the engine's CTimer::GetLerpedCurrentTick() function.
The returned value is always between Timer.CurrentTick() and Timer.CurrentTick() + TickQuantum depending on the current value reported by Timer.GetLerpFactor.

Tip

If you need consistent current frame time of the world simulation regardless of context, use World.GetLerpedCurrentTick() instead.

Return value: float with the current frame time in seconds.


Timer.GetLerpFactor()

Returns lerp factor of the current frame between two game ticks. Equivalent to the engine's CTimer::GetLerpFactor() function.

Return value: float


Timer.GetLerpFactor2()

Returns secondary lerp factor of the current frame between two game ticks. Equivalent to the engine's CTimer::GetLerpFactor2() function.

Return value: float


Timer.GetHighPrecisionTimer()

Returns current CPU time. Consistent across all running instances of the game on the same computer. Equivalent to the engine's CTimer::GetHighPrecisionTimer() function.

Return value: Timer.Value

Clone this wiki locally