Skip to content

Search

Documentation

replay

Records what a running game is fed and plays it back. A recording holds each tick's input, network arrivals and events; balaur run --record writes one.

On this page

Records what a running game is fed and plays it back. A recording holds each tick's input, network arrivals and events; balaur run --record writes one.

16 functions, 4 constants. Scripts reach it as replay::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
divergence_tick() -> replay::Divergence? — The first tick whose replay did not reproduce the recorded digest, or nil.
events(int, int) -> [replay::Event] — The events recorded between two ticks, each with its tick, kind, label and data.
header() -> replay::Header? — The loaded recording's project, start time, script fingerprint, its frame count and the ticks they span, and how it ended; nil with none loaded.
info(string) -> replay::Header? — The same summary for a recording on disk, without loading it. Nil when it cannot be read.
load(string) -> replay::Header? — Read a recording and put it in front of the engine, paused before its first tick. Nil when it cannot be read, which is logged.
marks(string, str?) -> [replay::Mark] — The ticks at which one replay source held a non-empty list under a key, and what it held.
pause() — Stop between ticks, holding the simulation still while the frame loop keeps drawing.
play() — Run the loaded recording, one recorded tick per frame.
position() -> int — The tick playback has reached.
record(string, replay::RecordOptions?) -> str? — Start recording into a file; call it before the code it records runs. Answers the path, or nil when the file cannot be written, which is logged.
recording() -> str? — The file being recorded into, or nil.
recording_name() -> string — A file-safe name for a recording starting now, so a list of them sorts by when they ran.
seek(int) — Run recorded ticks until playback reaches the given tick; forward only.
state() -> string — What playback is doing: STATE_STOPPED, STATE_PLAYING, STATE_PAUSED or STATE_SEEKING.
stop(str?) -> str? — Close the recording, naming why it ended, and return the file it wrote.
unload() — Drop the loaded recording and let the game run live again.

Constants

name value
STATE_PAUSED "paused"
STATE_PLAYING "playing"
STATE_SEEKING "seeking"
STATE_STOPPED "stopped"

Are you sure?