Entity category - Stingray Lua API Reference

Description

This category contains API elements related to the entity system.

Namespaces

Manager for creating and destroying entities.

Objects

A component that can store arbitrary values accessed by keys.
A component that handles animation blending for an entity.
A component that handles animation state machines for an entity.
A component that can store arbitrary values accessed by keys.
A component that stores a debug name for the entity.
Opaque object representing an entity.
A component that adds flow to an entity.
A component that can store arbitrary values accessed by keys.
A component that can store arbitrary values accessed by keys.
A component that assigns a scene graph (node hierarchy) to an entity.
A component that adds scripting support to entities.
A component that handles tags for an entity.
A component that lets entities be positioned in the world.
A component that links a unit to an entity.

Functions

Parameters

self :

stingray.DataComponent

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.

instance :

integer

The component instance.

tags :

string*

A variable number of strings representing the tags to add to the component instance.

The * notation indicates that there may be zero or more instances of the specified type.
Returns
This function does not return any values.
Parameters

self :

stingray.ScriptComponent

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.

script_name :

string

Name of the script.

Returns

stingray.Entity[]

An array of entities linked to the script name.

The [] notation indicates that this type is an array: a table in which the keys of the members are sequential integers, and the value of each element is an instance of the type shown.
Parameters

self :

stingray.ScriptComponent

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.

entity :

stingray.Entity

An optional entity to query for script components.

script_name :

string

Name of the script.

result_table :

table?

An optional table for the result.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns

any(stingray.Entity, integer)[]

Interleaved pairs of entities and component instance ids.

The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
The [] notation indicates that this type is an array: a table in which the keys of the members are sequential integers, and the value of each element is an instance of the type shown.

integer

The number of results written to the table.

Example usage:

-- We can pass a cached table for better performance or we can omit the parameter and have it allocated for us.
local components, num_components = script_component:instances_with_script("myscript_name", self._query_cache)
local arg1 = -- some argument
local arg2 = -- some argument
script_component:call_function(components, "some_function", arg1, arg2)

local entity = -- some entity
local arg1 = -- some argument
local arg2 = -- some argument
local components = script_component:instances_with_script(entity, "myscript_name", self._query_cache)
script_component:call_function(components, "some_function", arg1, arg2)