Skip to Content

utils

Random numbers from the engine stream, the license user name, the script file name and self-unload.


utils.random_int

utils.random_int(min, max)

Draws a uniformly distributed integer in min..max from the engine's shared random stream (tier0 RandomInt). A fractional argument is truncated toward zero; a numeric string is converted.

Returns: integer.

Errors: either argument is not a number (bad argument #N to 'random_int' (number expected, got <type>)).

utils.random_float

utils.random_float(min, max)

Draws a uniformly distributed number between min and max from the same stream (tier0 RandomFloat).

Returns: number.

Errors: either argument is not a number.

utils.user_name

utils.user_name()

Returns: the license user name as a string.

utils.script_name

utils.script_name()

Returns: the script's file name, including .lua. Non-ASCII characters are returned as ?.

utils.unload_script

utils.unload_script()

Schedules unloading of the calling script at the end of the current frame, after its render callbacks. See Frame order.

Returns: no values.

On this page