.. _stdlib_time_core: ==== 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 +++++++++ * :ref:`get_time_msec (ref: int64) : int ` * :ref:`get_time (ref: int64) : float ` * :ref:`get_delta_time_msec () : int ` * :ref:`get_delta_time () : float ` * :ref:`get_unscaled_delta_time_msec () : int ` * :ref:`get_unscaled_delta_time () : float ` * :ref:`get_time_msec () : int64 ` * :ref:`get_time () : float ` * :ref:`get_unscaled_time_msec () : int64 ` * :ref:`get_unscaled_time () : float ` * :ref:`get_time_usec () : int64 ` * :ref:`get_unscaled_time_usec () : int64 ` * :ref:`get_current_frame () : uint64 ` * :ref:`get_delta_time_usec () : int ` * :ref:`get_delta_time_scale () : float ` * :ref:`get_unscaled_delta_time_usec () : int ` * :ref:`get_sync_time () : float ` * :ref:`set_delta_time_scale (scale: float) : float ` * :ref:`get_clock () : clock ` * :ref:`ref_time_ticks () : int64 ` * :ref:`get_time_usec (ref: int64) : int ` * :ref:`get_time_nsec (ref: int64) : int64 ` .. _function-time_core_get_time_msec_int64: .. das:function:: 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 .. _function-time_core_get_time_int64: .. das:function:: 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) .. _function-time_core_get_delta_time_msec: .. das:function:: get_delta_time_msec() : int :Returns: * int - the time in milliseconds since the last frame to the current frame .. _function-time_core_get_delta_time: .. das:function:: get_delta_time() : float :Returns: * float - the time in seconds since the last frame to the current frame .. _function-time_core_get_unscaled_delta_time_msec: .. das:function:: get_unscaled_delta_time_msec() : int :Returns: * int - the time in milliseconds since the last frame to the current frame, ignoring time scaling .. _function-time_core_get_unscaled_delta_time: .. das:function:: get_unscaled_delta_time() : float :Returns: * float - the time in seconds since the last frame to the current frame, ignoring time scaling .. _function-time_core_get_time_msec: .. das:function:: get_time_msec() : int64 :Returns: * int64 - the time in milliseconds since the start of the program to the current frame .. _function-time_core_get_time: .. das:function:: get_time() : float :Returns: * float - the time in seconds since the start of the program to the current frame .. _function-time_core_get_unscaled_time_msec: .. das:function:: get_unscaled_time_msec() : int64 :Returns: * int64 - the time in milliseconds since the start of the program to the current frame, ignoring time scaling .. _function-time_core_get_unscaled_time: .. das:function:: get_unscaled_time() : float :Returns: * float - the time in seconds since the start of the program to the current frame, ignoring time scaling .. _function-public_time_get_time_usec: .. das:function:: get_time_usec() : int64 :Returns: * int64 - the time in microseconds since the start of the program .. _function-public_time_get_unscaled_time_usec: .. das:function:: get_unscaled_time_usec() : int64 :Returns: * int64 - the time in microseconds since the start of the program, ignoring time scaling .. _function-public_time_get_current_frame: .. das:function:: get_current_frame() : uint64 :Returns: * uint64 - the current frame number since the start of the program .. _function-public_time_get_delta_time_usec: .. das:function:: get_delta_time_usec() : int :Returns: * int - the time in microseconds since the last on_update call .. _function-public_time_get_delta_time_scale: .. das:function:: get_delta_time_scale() : float :Returns: * float - the time scaling factor .. _function-public_time_get_unscaled_delta_time_usec: .. das:function:: get_unscaled_delta_time_usec() : int :Returns: * int - the time in microseconds since the last on_update call, ignoring time scaling .. _function-public_time_get_sync_time: .. das:function:: get_sync_time() : float :Returns: * float - the time in seconds synced between client & server .. _function-public_time_set_delta_time_scale_float: .. das:function:: 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 .. _function-builtin_get_clock: .. das:function:: get_clock() : clock :Returns: * :ref:`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) .. _function-builtin_ref_time_ticks: .. das:function:: ref_time_ticks() : int64 :Returns: * int64 - the current reference timer tick value .. _function-builtin_get_time_usec_int64: .. das:function:: 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 .. _function-builtin_get_time_nsec_int64: .. das:function:: 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