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.
|
Returns the current playback frame.
|
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.
|
|
Indicates whether or not the replay system is currently in playback mode.
|
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.
|
|
Returns the number of frames of data have been recorded by the replay system.
|
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.
|
|
Records a debug line of the specified color, drawn between points p1 and p2.
|
Parameters Returns | This function does not return any values. |
Note that the recorded debug lines are only drawn during playback.
|
Records a line of debug text to be drawn in the specified color at the specified position in screen space.
|
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.
|
Records a line of debug text to be drawn in the specified color at the specified position in world space.
|
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.
|
Sets the current playback frame.
|
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. |
|
Controls how data for the specified unit should be recorded.
|
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.
|
Starts playing back the recorded data.
|
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.
|
Ends playback, and returns to recording mode.
|
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 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.
|
Specifies that recording should be disabled for the unit.
|
|
Specifies that the transforms of all nodes in the unit's scene graph are recorded.
|
This means that the
unit's entire animation is saved.
This is the default recording mode.