Script - stingray.Script namespace reference - Stingray Lua API Reference

stingray.Script namespace reference

Description

The Script interface contains helper functions for manipulating scripts.

Functions

Parameters
This function does not accept any parameters.
Returns

string

The current script call stack.

Parameters

parameters :

any(string, number)+

One or more of the options listed under Garbage Collection Flags, each followed by the value to set for that option.

The + notation indicates that there may be one or more instances of the specified type.
The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
Returns
This function does not return any values.

For example:

Parameters

string_rep :

string

The string to deserialize into an object.

Returns

any(string, number, boolean, table, stingray.Vector3, stingray.Vector3Box, stingray.Matrix4x4, stingray.Matrix4x4Box, stingray.IdString32, stingray.IdString32Box, stingray.IdString64, stingray.IdString64Box)

The deserialized Lua object.

The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.

Note: The string must have been created by a call to serialize(). If not, you will receive an error.

Parameters

resource :

string

The resource name of the Lua script you want to require.

Returns

boolean

Returns true if the script exists among the loaded resourcers.

Parameters
This function does not accept any parameters.
Returns

integer

The offset of Lua indices.

Parameters

resource :

string

The resource name of the Lua script you want to load.

Returns

fun(nil:any*)?

An anonymous Lua function that causes the script to be run.

The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..
The ? notation indicates that this type is optional: there may be zero or one instances of it.
Parameters

data :

any(string, number, boolean, table, stingray.Vector3, stingray.Vector3Box, stingray.Matrix4x4, stingray.Matrix4x4Box, stingray.IdString32, stingray.IdString32Box, stingray.IdString64, stingray.IdString64Box)

The Lua object you want to serialize.

The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
Returns

string

The string representation of the data object.

Parameters

offset :

integer

The offset of Lua indices.

Returns
This function does not return any values.
Parameters

s :

integer

The memory size of the temporary objects buffer.

Returns
This function does not return any values.

If you have a function that uses a lot of temporary objects, you can use this call to reset the temporary buffer and free all of those objects. This function does not export any of those objects to variables that live beyond the length of the function call. These variables might be assigned new values because the system considers them "freed".

Parameters

s :

integer

The memory size of the temporary objects buffer.

Returns
This function does not return any values.

Sets how much of the buffer for temporary objects created and maintained by the engine is considered in use.

If you have a function that uses a lot of temporary objects, you can use this call to reset the temporary buffer and free all of those objects. This function does not export any of those objects to variables that live beyond the length of the function call. These variables might be assigned new values because the system considers them "freed".

Parameters
This function does not accept any parameters.
Returns

integer

The memory size of the temporary objects buffer.

Parameters
This function does not accept any parameters.
Returns

integer

The memory size of the temporary objects buffer.

Returns the size currently in use in the memory buffer containing temporary objects.

Parameters

obj :

any

The object whose type you want to retrieve.

Returns

string

The type name of the object.

Garbage Collection Flags

The constants listed in this group can be passed as arguments to stingray.Script.configure_garbage_collection().

A value of 0.1 means 10%. So, if Lua is using 20 MB of memory, it is allowed to use 2 MB of garbage. A higher value here increases your memory usage, but reduces the time required for garbage collection.

The default value is 0.1.

This will stall the game. So, it is generally something you want to avoid, but it can save from crashing if there is a runaway process generating garbage. The default value is 1.0.

The default value is 10.

As the amount of garbage approaches this value, more and more time is spent collecting each frame (up to the maximum collect time).

The default value is 0.5.

The default value is 0.5.