Time

This module contains functions for retrieving time-related information, such as the time since the program started, the time since the last frame, and the Unix time.

To use this module, include the following line in your project file:

require engine.time_core // or require engine.core

Functions

get_time_msec(ref: int64): int

retrieves the time in milliseconds since the reference time

Usage example:

let refTime = ref_time_ticks()
// do something
let elapsedTimeMsec = get_time_msec(refTime)
Arguments:
  • ref : int64 - the reference time, get it with ref_time_ticks()

Returns:
  • int - the time in milliseconds since the specified tick

get_time(ref: int64): float
Arguments:
  • ref : int64 - the reference time, get it with ref_time_ticks()

Returns:
  • float - the time in seconds since the reference time

Usage example:

let refTime = ref_time_ticks()
// do something
let elapsedTimeSec = get_time(refTime)
get_delta_time_msec(): int
Returns:
  • int - the time in milliseconds since the last frame to the current frame

get_delta_time(): float
Returns:
  • float - the time in seconds since the last frame to the current frame

get_unscaled_delta_time_msec(): int
Returns:
  • int - the time in milliseconds since the last frame to the current frame, ignoring time scaling

get_unscaled_delta_time(): float
Returns:
  • float - the time in seconds since the last frame to the current frame, ignoring time scaling

get_time_msec(): int64
Returns:
  • int64 - the time in milliseconds since the start of the program to the current frame

get_time(): float
Returns:
  • float - the time in seconds since the start of the program to the current frame

get_unscaled_time_msec(): int64
Returns:
  • int64 - the time in milliseconds since the start of the program to the current frame, ignoring time scaling

get_unscaled_time(): float
Returns:
  • float - the time in seconds since the start of the program to the current frame, ignoring time scaling

get_time_usec(): int64
Returns:
  • int64 - the time in microseconds since the start of the program

get_unscaled_time_usec(): int64
Returns:
  • int64 - the time in microseconds since the start of the program, ignoring time scaling

get_current_frame(): uint64
Returns:
  • uint64 - the current frame number since the start of the program

get_delta_time_usec(): int
Returns:
  • int - the time in microseconds since the last on_update call

get_delta_time_scale(): float
Returns:
  • float - the time scaling factor

get_unscaled_delta_time_usec(): int
Returns:
  • int - the time in microseconds since the last on_update call, ignoring time scaling

get_sync_time(): float
Returns:
  • float - the time in seconds synced between client & server

set_delta_time_scale(scale: float): float

change the time scaling factor. The value is clamped to the range [0.0, 1000.0] and the new time scaling factor is returned.

Arguments:
  • scale : float - the factor to scale the time by

Returns:
  • float - the new time scaling factor

get_clock(): clock
Returns:
  • clock - the value that represents the time in seconds since 00:00 hours, Jan 1, 1970 UTC (i.e., the current unix time)

Usage example:

let unixTime = get_clock() // note that the returned value is not an integer
let seconds = int64(unixTime)
ref_time_ticks(): int64
Returns:
  • int64 - the current reference timer tick value

get_time_usec(ref: int64): int

Retrieves the time in microseconds since the reference time.

Usage example::

let refTime = ref_time_ticks() // do something let elapsedTimeUsec = get_time_usec(refTime)

Arguments:
  • ref : int64 - the reference time, get it with ref_time_ticks()

Returns:
  • int - the time in microseconds since the specified tick

get_time_nsec(ref: int64): int64

Retrieves the time in nanoseconds since the reference time.

Usage example::

let refTime = ref_time_ticks() // do something let elapsedTimeNsec = get_time_nsec(refTime)

Arguments:
  • ref : int64 - the reference time, get it with ref_time_ticks()

Returns:
  • int64 - the time in nanoseconds since the specified tick