Vector4Box - stingray.Vector4Box object reference - Stingray Lua API Reference

stingray.Vector4Box object reference

Description

A "box" that stores a Vector4 object across multiple frames.

Normally, vectors are temporary objects that can only be safely used within a single frame. When you need a vector value to persist across multiple frames, you can call Vector4Box.store() to store the vector in a Vector4Box, and Vector4Box.unbox() to retrieve the stored values.

For more information, see Object Lifetimes and Userdata Binding.

Operators

Accessing components: []

You can set and retrieve component values by using the [] operator. Use the indices 1 or "x" for the X component, 2 or "y" for the Y component, 3 or "z" for the Z component, and 4 or "w" for the W component. For example:

yComponentValue = vectorBox[2]
zComponentValue = vectorBox["z"]

Data Members

w : number

The W component value last stored in the box.

x : number

The X component value last stored in the box.

y : number

The Y component value last stored in the box.

z : number

The Z component value last stored in the box.

Functions

Parameters

self :

stingray.Vector4Box

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

vector :

stingray.Vector4

The vector to store in the box.

Returns
This function does not return any values.
Parameters

self :

stingray.Vector4Box

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

x :

number

The X component value to store in the box.

y :

number

The Y component value to store in the box.

z :

number

The Z component value to store in the box.

w :

number

The W component value to store in the box.

Returns
This function does not return any values.
Parameters

self :

stingray.Vector4Box

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

stingray.Vector4

The vector retrieved from the box.