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

Description

Represents a game world.

Functions

Parameters

self :

stingray.World

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

number

The delta time value.

Parameters

self :

stingray.World

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.Entity[]

A table with all the entities in the world.

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.World

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.Replay?

The replay object owned by the world, or nil if the replay system was not enabled for the world.

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

self :

stingray.World

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.ScatterSystem

The scatter system owned by the world.

The brush system is used for mass unit spawning.

Parameters

self :

stingray.World

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.StoryTeller

The storyteller owned by the world.

Parameters

self :

stingray.World

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

number

The current time in the world.

Parameters

self :

stingray.World

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.

delta_time :

number?

The time step that the world should use when updating. Optional; if not specified, the application's global time step will be used.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.

You should typically call this function in your implementation of the update() callback you provide to the engine in your Lua boot script.

Instead of calling update(), you can call update_animations() and then update_scene() separately. This allows your boot script to do some processing in between the update of the animations and the update of the scene.

Parameters

self :

stingray.World

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.

delta_time :

number?

The time step that the world should use when updating. Optional; if not specified, the application's global time step will be used.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.
Parameters

self :

stingray.World

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.

delta_time :

number

The time step that the world should use when updating.

callback :

fun(nil:nil)

A callback function that will be invoked.

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..
Returns
This function does not return any values.

This may be useful on the PlayStation 3, because the animation player update runs entirely on the SPUs, which frees the PPU to do other things. Thus, you can save precious milliseconds by putting some of your Lua updates in the callback function so that its code can be executed in parallel. Note that you must not create or destroy animations in the callback, since that would interfere with the update of the animation player.

Parameters

self :

stingray.World

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.

delta_time :

number?

The time step that the world should use when updating. Optional; if not specified, the application's global time step will be used.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.

Script data

Parameters

self :

stingray.World

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.

indices :

any(integer, string)+

One or more indices for the data, which may be integers or strings.

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

any

The data previously saved at the specified sequence of indices.

Similar to Unit.get_data().

Parameters

self :

stingray.World

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.

indices :

any(integer, string)+

One or more indices for the data, which may be integers or strings.

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

boolean

Returns true if a data value is stored at the specified sequence of indices, or false otherwise.

Similar to Unit.has_data().

Parameters

self :

stingray.World

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.

indices :

any(integer, string)

One or more indices for the data, which may be integers or strings.

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

value :

any

The value to store.

Returns
This function does not return any values.

You can retrieve the data later by passing the same indices in a call to get_data(). Similar to Unit.set_data().

Debugging

Parameters

self :

stingray.World

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
This function does not return any values.
Parameters

self :

stingray.World

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.

disable_depth_test :

boolean?

If true, lines will be drawn without depth test. Optional; default is false.

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

stingray.LineObject

The newly created line object.

Parameters

self :

stingray.World

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.Matrix4x4

The position and orientation of the camera.

Parameters

self :

stingray.World

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.

line :

stingray.LineObject

The line object to be destroyed.

Returns
This function does not return any values.

Development only

The elements in this group are only available in development builds.

Do not use them in your final builds.

Parameters

self :

stingray.World

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.

effect_id :

integer?

The ID of the particle effect. Optional; if specified, the return value will give the number of particles in the specified particle effect only.

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

cloud_index :

integer?

The index of a particle cloud. Optional; if specified, the return value will give the number of particles in the specified cloud only.

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

integer

The number of active particles.

Parameters

self :

stingray.World

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.

camera :

stingray.Camera

The override camera.

Returns
This function does not return any values.

This may be very useful for debugging problems related to culling.

GUI

Parameters

self :

stingray.World

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 coordinate of the screen space. Optional.

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

y :

number?

The y coordinate of the screen space. Required if and only if x is specified.

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

params :

any(string, number)*

Settings for the gui. The possible values are:

  • "scale": Specifies the amount with which to scale the coordinates in gui. If you specify this parameter, you must follow it with two additional numbers that specify scale factors for the width and height respectively. With a scale of 2 an object that has size 100 pixels in the gui will be drawn with 200 pixels on the screen.
  • "immediate": If specified, the gui will be run in immediate mode. This means that everything you place on the gui will be drawn for just one frame. You have to redraw the objects you want to see every frame. If not in immediate mode, objects remain until you explicitly remove them.
  • "dock_right": Specifies that the gui should dock to the right margin when the window is resized.
  • "dock_top": Specifies that the gui should dock to the top when the window is resized.
The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
The * notation indicates that there may be zero or more instances of the specified type.
Returns

stingray.Gui

The newly created gui.

(0,0) is the bottom left corner of the screen.

Note that to find the size of the screen, you can call Application.back_buffer_size().

Parameters

self :

stingray.World

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.

resource :

string

The video resource to play.

loop :

boolean?

Determines whether or not the video loops. If true, the video will continue playing to the start when it reaches the end, otherwise it will freeze at the last frame. Optional; the default is true.

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

stingray.VideoPlayer

The newly created video player.

The video player can be used with Gui video objects.

This function will return trigger a script error if the video player is not supported. To test if the video player is supported, use [has_video_player()].

Note: This video playing interface is under development. It should be considered temporary and currently only works on Windows platforms.

Parameters

self :

stingray.World

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.

pose :

stingray.Matrix4x4

The position and orientation of the gui in 3D space.

width :

number

The ratio between Gui units and world space units along the X axis of the Gui's drawing plane. Increasing this value causes shapes drawn in the Gui to appear smaller than in world space, and vice-versa.

height :

number

The ratio between Gui units and world space units along the Y axis of the Gui's drawing plane. Increasing this value causes shapes drawn in the Gui to appear smaller than in world space, and vice-versa.

params :

string*

Settings for the gui. The possible values are:

  • "shadow_caster": Specifies that the objects in the GUI should cast shadows. Note that for this to work, the objects must also be drawn with a shader that supports shadow casting, such as the base shader.
  • "immediate": If specified, the gui will be run in immediate mode. This means that everything you place on the gui will be drawn for just one frame. You have to redraw the objects you want to see every frame. If not in immediate mode, objects remain until you explicitly remove them.
The * notation indicates that there may be zero or more instances of the specified type.
Returns

stingray.Gui

The newly created gui.

Parameters

self :

stingray.World

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.

gui :

stingray.Gui

The gui to remove from the world.

Returns
This function does not return any values.
Parameters

self :

stingray.World

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.

video_player :

stingray.VideoPlayer

The video player to remove.

Returns
This function does not return any values.

Video players consume a lot of resources, so you should destroy the video player as soon as you are done with it.

Parameters

self :

stingray.World

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.

id :

integer

The id of the gui

Returns

stingray.Gui

The gui with that id.

Levels

Parameters

self :

stingray.World

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.

level :

stingray.Level

The name of the level you want to destroy.

Returns
This function does not return any values.

Take care to clean up the units spawned in Lua (or in the level flow editor) for these are not destroyed when the level is unloaded. You are not required to call this function, since all levels will be destroyed when the world ends. Nested levels cannot be destroyed using this function.

Parameters

self :

stingray.World

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.Level[]

A table that contains all levels in the world.

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.

Note that the table returned by this function does not contain nested levels; use Level.nested_levels() to access those.

Parameters

self :

stingray.World

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.

name :

string

The name of the level you want to load.

position :

stingray.Vector3?

Optional; the position of the level.

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

rotation :

stingray.Quaternion?

Optional; the rotation of the level.

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

scale :

stingray.Vector3?

Optional; the per-axis scale factors of the level.

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

stingray.Level

The loaded level in the world.

If position, rotation, scale are not supplied, the level will be loaded at the world origin with the default rotation and scale.

Parameters

self :

stingray.World

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.

name :

string

The name of the level you want to load.

obj_set_names :

string[]

A table that contains the names of the object sets to spawn.

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.

ignored_obj_set_names :

string[]

A table that contains object set names that will be ignored.

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.

position :

stingray.Vector3?

Optional; the position of the level.

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

rotation :

stingray.Quaternion?

Optional; the rotation of the level.

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

scale :

stingray.Vector3?

Optional; the per-axis scale factors of the level.

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

stingray.Level

The loaded level in the world.

Units, particle effects, sounds, triggers, prototypes and volumes can be added to object sets using the level editor. An object can belong to several object sets. An object will be spawned if any of these conditions is true:

  • it is a member of any of the named object sets;
  • it is not a member of any object set;
  • all the object sets it is a member of are listed in the ignored_object_set_names parameter.

For performance reasons, prototypes and volumes do not take the ignored_object_set_names parameter into account. They are spawned only if they are members of any of the named object sets, or if they do not belong to any object set. This allows the engine to merge prototype and volume geometry into larger batches.

You can get a list of all object set names within a level resource by calling the LevelResource.object_set_names() function.

Parameters

self :

stingray.World

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

integer

The total number of levels in the world.

Particles

Parameters

self :

stingray.World

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.

effect_id :

integer

The integer ID of the particle effect to test.

Returns

boolean

true if the particle effect is spawning particles, or false otherwise.

Parameters

self :

stingray.World

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.

effect_name :

string

The name of the particle effect to be created.

position :

stingray.Vector3

The position of the particle effect.

rotation :

stingray.Quaternion?

The orientation of the particle effect. Optional.

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

scale :

stingray.Vector3?

The scaling factor of the particle effect. Optional.

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

integer

An integer ID for the newly created particle effect.

Parameters

self :

stingray.World

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.

effect_id :

integer

The integer ID of the particle effect to be destroyed.

Returns
This function does not return any values.
Parameters

self :

stingray.World

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.

effect_name :

string

The name of the particle effect whose index will be checked.

variable_name :

string

The name of the variable to find within the particle effect.

Returns

integer

The index of the specified variable within the particle effect.

Parameters

self :

stingray.World

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.

effect_id :

integer

The integer ID of the particle effect to move.

position :

stingray.Vector3

The new position of the particle effect.

rotation :

stingray.Quaternion?

The new orientation of the particle effect. Optional.

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

scale :

stingray.Vector3?

The new scaling factor of the particle effect. Optional.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.

Note that existing particles are not affected.

Parameters

self :

stingray.World

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.

collision_filter :

string

The collision filter to set.

Returns
This function does not return any values.

If an effect_id is specified, the collision filter is set for just that effect. Otherwise, the default collision_filter to be used for all particle effects is set.

Parameters

self :

stingray.World

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.

effect_id :

integer

The ID of the particle effect.

variable_index :

integer

The index of the variable whose value will be set.

value :

stingray.Vector3

The value to set for the specified variable within the particle effect.

Returns
This function does not return any values.
Parameters

self :

stingray.World

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.

effect_id :

integer

The integer ID of the particle effect to stop.

Returns
This function does not return any values.

The effect will be destroyed when all the particles have been played out.

Physics

Parameters

self :

stingray.World

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.PhysicsWorld

The physics world.

Parameters

self :

stingray.World

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.

name :

string

The name of the vector field to retrieve, such as "wind".

Returns

stingray.VectorField

The retrieved vector field.

Shading environments

Parameters

self :

stingray.World

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.

name :

string

The name of the shading environment to be created.

Returns

stingray.ShadingEnvironment

The newly created shading environment.

Parameters

self :

stingray.World

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.

environment :

stingray.ShadingEnvironment

The shading environment to be destroyed.

Returns
This function does not return any values.
Parameters

self :

stingray.World

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.

environment :

stingray.ShadingEnvironment

The shading environment to be changed.

name :

string

The name of the new shading environment data the environment should use.

Returns
This function does not return any values.

Units

Parameters

self :

stingray.World

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.

unit :

stingray.Unit

The unit to be destroyed.

Returns
This function does not return any values.
Parameters

self :

stingray.World

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

integer

The number of units in the world.

This includes units that were placed into levels in the editor and spawned when the levels were loaded, and units that have been spawned dynamically on the fly.

Parameters

self :

stingray.World

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.

unit_name :

string

The name of the unit to spawn.

transform :

stingray.Matrix4x4?

Optional. The starting position and orientation for the new unit. If omitted, the unit will be spawned at the default position (the origin of the 3D coordinate system), with a default rotation.

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

stingray.Unit

The newly created Unit object.

Parameters

self :

stingray.World

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.

unit_name :

string

The name of the unit to spawn.

position :

stingray.Vector3?

Optional. The starting position for the new unit. If omitted, the unit will be spawned at the default position (the origin of the 3D coordinate system).

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

orientation :

stingray.Quaternion?

The starting orientation for the new unit. If omitted, the unit will be spawned with a default rotation.

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

stingray.Unit

The newly created Unit object.

Parameters

self :

stingray.World

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.Unit[]

A table that contains all Unit objects that exist in the world.

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.

This includes units that were placed into levels in the editor and spawned when the levels were loaded, and units that have been spawned dynamically on the fly.

Parameters

self :

stingray.World

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.

resource_name :

string

The resource name of the units to look for.

Returns

stingray.Unit[]

A table that contains all Unit objects that exist in the world and that match the specified resource type.

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.World

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.

id :

string

The id of the unit to look for.

Returns

stingray.Unit?

A unit with the specified id, or nil if no unit exists with that id.

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

If no such unit exists, nil is returned.

Parameters

self :

stingray.World

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.

name :

string

The name of the unit to look for.

Returns

stingray.Unit?

A unit with the specified name, or nil if no unit exists with that name.

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

If no such unit exists, nil is returned. If there are multiple units with the same name, a random one will be returned.

Parameters

self :

stingray.World

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.

unit :

stingray.Unit

The unit to be updated.

Returns
This function does not return any values.

This can be used to implement units that are dependent on other units positions in complicated ways that cannot be expressed solely by linking units through calls to link_unit().

It is recommended that you use this approach sparingly.

Note that update_unit() does not automatically update linked child units. You have to call update_unit() on each child unit manually, if you want their positions to be updated to reflect the new position of the parent.