Globals
TruScript features a set of global functions and properties that can be accessed without a module prefix.
Properties
The instance this script is attached to.
The root DataModel object of the instance tree. Game-wide services such as the world, players, and game systems are accessed through it.
The world containing all parts, characters, and physical objects. This is a shorthand for game.World.
Functions
Prints the given values to the output log.
Prints a string replacing placeholders ("My name is {0} and I like {1}!") with the remaining arguments. This is a shorthand for print(string.format(format, ...args))
Prints the given values to the output log as a warning.
Raises an error with the given values as the error message, stopping script execution and showing the call stack trace.
Pauses the script for the shortest possible time. Returns the actual time waited, in seconds.
Pauses the script and resumes when at least the given number of seconds has passed. The script scheduler will try to resume as soon as the target time elapsed, but the actual time waited may be longer than the specified time. Returns the actual time waited, in seconds.
Runs the given function concurrently as a new coroutine, passing any additional arguments to it. Returns a reference to the newly-created coroutine.
Returns an enumerator for use in a for loop that counts from 0 up to (but not including) end, in steps of 1. For example, for i in range(3): visits 0, 1, and 2.
Returns an enumerator for use in a for loop that counts from start up to (but not including) end, in steps of 1.
Returns an enumerator for use in a for loop that counts from start toward end (exclusive) in increments of step. A negative step counts downward. The step's sign must match the range's direction, and a step of zero is an error.
Returns the current time as the number of seconds since the Unix epoch (January 1, 1970 UTC), with fractional millisecond precision.
Converts the value to a number. Returns NaN when the value cannot be parsed as a number.
Converts the value to a boolean using truthiness rules. As a special case, the string "false" converts to false, so this function is useful for processing data from remote sources like JSON.
Converts the value to its string representation.
Swaps the values of two variables, given their names as strings. For example swap("x", "y") exchanges the values of x and y. Both names must be valid and in-scope.