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

stingray.Replay object reference

Description

The Replay object can be used to replay events that have occurred in the game world.

By default, the replay object records the position of all moving units, as well has debug lines and debug texts recorded with the record_debug_line(), record_screen_debug_text() and record_world_debug_text() functions. When a replay is played back, the recorded units will be moved automatically to their recorded positions, and the recorded debug lines and debug texts will be drawn.

The Replay class is intended primarily as a debug tool for AI and other script related tasks. If something strange happens in a game, you can pause it using the replay system, rewind back time and examine the debug texts and debug lines to find out why the AIs made the decisions they did.

The replay system records its data in a circular or ring buffer. On the PC this buffer defaults to 50 MB. On more memory-constrained platforms, it is just 1 MB. The size of this buffer and the number of units in the world that you record data for determines how far "back in time" you can go when you rewind.

The replay system is only available in development mode, and only on a World created with the Application.ENABLE_REPLAY flag. When replay has been enabled for a world, you can access the replay controller by calling World.replay().

When playing back, the Replay system will move the units in the world to their recorded positions. You should avoid doing your own unit movement at the same time, to prevent interference with the replay system.

Note: The replay system should be considered a work in progress. The API may change in future versions.

Functions

Parameters

self :

stingray.Replay

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 frame currently being played back.

Parameters

self :

stingray.Replay

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

boolean

Returns true if the replay system is currently in playback mode, and false if it is currently recording.

Parameters

self :

stingray.Replay

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 recorded frames.

Parameters

self :

stingray.Replay

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.

color :

stingray.Vector4

The color of the line.

p1 :

stingray.Vector3

The point at which the line begins.

p2 :

stingray.Vector3

The point at which the line ends.

Returns
This function does not return any values.

Note that the recorded debug lines are only drawn during playback.

Parameters

self :

stingray.Replay

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.

color :

stingray.Vector4

The color of the text.

position :

stingray.Vector2

The position at which to draw the text, in screen space 2D coordinates.

text :

string

The text to be drawn.

Returns
This function does not return any values.

Note that the text is only drawn during playback.

Parameters

self :

stingray.Replay

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.

color :

stingray.Vector4

The color of the text.

position :

stingray.Vector3

The position at which to draw the text, in world coordinates.

text :

string

The text to be drawn.

Returns
This function does not return any values.

Note that the text is only drawn during playback.

Parameters

self :

stingray.Replay

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.

frame :

integer

The frame to play back.

Returns
This function does not return any values.
Parameters

self :

stingray.Replay

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 for which the data is recorded.

mode :

integer

The mode of recording. May be any [record mode] value.

Returns
This function does not return any values.

By default, the replay system only records the root position of animated units, in order to reduce the memory used by the replay buffer.

Parameters

self :

stingray.Replay

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.

The playback starts at the first frame of the recording.

Parameters

self :

stingray.Replay

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.

Record modes

The constants in this group can be passed in calls to set_unit_record_mode() in order to set the recording mode used by the replay system for a particular unit.

No data will be saved.

This means that the unit's entire animation is saved.

This is the default recording mode.