Skip to content

$time

Game time, wall time, tick intervals and unit conversion.

26 natives. Read-only natives only look things up; the rest change something. Parameter types use the language's names (Types).

decomposed_duration_to_seconds

read-only
$time.decomposed_duration_to_seconds(days: int, hours: int, minutes: int, seconds: int) -> int

Given a duration in days, hours, minutes, seconds, return the duration in seconds.

ParameterTypeMeaning
daysintCount of days in the time duration
hoursintCount of hours in the time duration
minutesintCount of minutes in the time duration
secondsintCount of seconds in the time duration

Returns int: The duration in seconds.

get_decomposed_date

read-only
$time.get_decomposed_date() -> list

Return the decomposed date in a list formatted as [year, month, day, hour, minute, second].

Returns list: The decomposed date in the format [year, month, day, hour, minute, second].

get_decomposed_time_value_list

read-only
$time.get_decomposed_time_value_list(time: int) -> list

Given a time in seconds, return the decomposed time in a list formatted as [days, hours, minutes, seconds].

ParameterTypeMeaning
timeintThe time in seconds to decompose.

Returns list: The decomposed time values in the format [days, hours, minutes, seconds].

get_decomposed_time_value_list_ms

read-only
$time.get_decomposed_time_value_list_ms(time_ms: int) -> list

Given a time in seconds, return the decomposed time in a list formatted as [days, hours, minutes, seconds].

ParameterTypeMeaning
time_msintThe time in milliseconds to decompose.

Returns list: The decomposed time values in the format [days, hours, minutes, seconds].

get_gameplay_tick_interval

read-only
$time.get_gameplay_tick_interval() -> float

Get the gameplay time in seconds between frames from global_time.vscript singleton. If global_time does not exist, returns the same value as get_tick_interval().

Returns float: Time in seconds.

get_gameplay_tick_interval_ms

read-only
$time.get_gameplay_tick_interval_ms() -> int

Get the gameplay time in milliseconds between frames from global_time.vscript singleton. If global_time does not exist, returns the same value as get_tick_interval_ms().

Returns int: Time in milliseconds.

get_gameplay_time_ms

read-only
$time.get_gameplay_time_ms() -> int

Get the current gameplay time in milliseconds from global_time.vscript singleton.

Returns int: Time in milliseconds.

get_gpu_actual_time

read-only
$time.get_gpu_actual_time() -> float

Get the actual previous frame time for the GPU.

Returns float: Time in seconds.

get_out_actual_time

read-only
$time.get_out_actual_time() -> float

Get the actual previous frame time for output.

Returns float: Time in seconds.

get_out_target_time

read-only
$time.get_out_target_time() -> float

Get the desired max frame time for output.

Returns float: Time in seconds.

get_sim_actual_time

read-only
$time.get_sim_actual_time() -> float

Get the actual previous frame time for the simulation.

Returns float: Time in seconds.

get_sim_frame_index

read-only
$time.get_sim_frame_index() -> int

Get the increment-only sim frame index

Returns int: frame index, may be 0 for first frame

get_sim_frame_time_base

read-only
$time.get_sim_frame_time_base() -> float

Returns the base sim frame time in seconds. This is the duration of a frame on the server. Clients may have it altered by time.get_sim_frame_time_scale().

Returns float: Base sim frame time in seconds.

get_sim_frame_time_scale

read-only
$time.get_sim_frame_time_scale() -> float

Returns the sim frame time scale factor. On a client, this may scale time.get_sim_frame_time_base() to reduce ticks and improve performance.

Returns float: Base sim time multiplier.

get_sim_ring_commit_success_frame_index

read-only
$time.get_sim_ring_commit_success_frame_index() -> int

Get last sim frame index where a ring commit was successful

Returns int: last sim frame index where a ring commit was successful

get_sim_target_time

read-only
$time.get_sim_target_time() -> float

Get the desired max frame time for the simulation.

Returns float: Time in seconds.

get_system_time_ms

read-only
$time.get_system_time_ms() -> int

Get the system time in milliseconds at the start of this frame.

Returns int: Time in milliseconds.

get_tick_interval

read-only
$time.get_tick_interval() -> float

Get the time in seconds between frames.

Returns float: Time in seconds.

get_tick_interval_ms

read-only
$time.get_tick_interval_ms() -> int

Get the time in milliseconds between frames.

Returns int: Time in milliseconds.

get_time_ms

read-only
$time.get_time_ms() -> int

Get the current time since app startup in milliseconds.

Returns int: Time in milliseconds.

get_virtual_time

read-only
$time.get_virtual_time() -> int

Get the current virtual time (frame number).

Returns int: Time in frames.

get_virtual_time_of_last_draw

read-only
$time.get_virtual_time_of_last_draw() -> int

Get the virtual time of the previous frame with a draw event. This is not rollback safe. This may be < current virtual time - 1 if the client fell behind and rolled forth to catch up, skipping leading edge frames.

Returns int: Time in frames.

invalidate_gameplay_time_cache

$time.invalidate_gameplay_time_cache()

Invalidate cached gameplay times. Called by global_time.vscript when tick interval scale changes.

ms_to_seconds

read-only
$time.ms_to_seconds(ms: int) -> float

Convert a time duration in milliseconds to seconds. Safe only for time durations, not absolute clock values.

ParameterTypeMeaning
msintTime in milliseconds.

Returns float: Time in seconds.

seconds_to_ms

read-only
$time.seconds_to_ms(seconds: float) -> int

Convert a time duration in seconds to milliseconds. Safe only for time durations, not absolute clock values.

ParameterTypeMeaning
secondsfloatTime in seconds.

Returns int: Time in milliseconds.

utc_s_to_decomposed_date

read-only
$time.utc_s_to_decomposed_date(utc_s: int) -> list

Return the decomposed date of a utc timestamp in a list formatted as [year, month, day, hour, minute, second].

ParameterTypeMeaning
utc_sintThe time in seconds utc to decompose.

Returns list: The decomposed date in the format [year, month, day, hour, minute, second].