Archmage.Duration
A length of time in nanoseconds, the type of a duration field.
Inherits: RefCounted
In the config files, a duration is null when it is zero, or an array that starts with a unit: [0, seconds], [1, milliseconds], [2, microseconds], [3, nanoseconds] or [4, seconds, nanoseconds]. For example, 1.5 seconds is [1, 1500].
Properties
Section titled “Properties”nanoseconds
Section titled “nanoseconds”var nanoseconds: intThe length in nanoseconds. It may be negative.
Constructor
Section titled “Constructor”Archmage.Duration.new(ns: int = 0)Methods
Section titled “Methods”from_json()
Section titled “from_json()”static func from_json(v: Variant, e: Archmage.ParseError = null) -> Archmage.DurationReturns the duration in v, a parsed JSON value. For null and an empty array, returns a zero duration. For any other value that is not a valid duration, records the error in e (see Archmage.ParseError.report()) and returns a zero duration.
seconds_from_json()
Section titled “seconds_from_json()”static func seconds_from_json(v: Variant, e: Archmage.ParseError = null) -> floatReturns the duration in v in seconds, such as 1.5. It accepts the same values as from_json() and records the same errors. Code generated with ARCHMAGE_GD_FLOAT_DURATION=true calls it for every duration.
to_json()
Section titled “to_json()”func to_json() -> VariantReturns the duration in the format of the config files.
to_seconds()
Section titled “to_seconds()”func to_seconds() -> floatReturns the duration in seconds, such as 1.5. Use it for Godot APIs that take seconds, such as SceneTree.create_timer().
to_milliseconds()
Section titled “to_milliseconds()”func to_milliseconds() -> intReturns the duration in whole milliseconds, truncated toward zero.