Runs¶
Your own recent runs, finished or not: each attempt at a track from the race's start until a restart from the
beginning, the finish, or leaving the track (checkpoint respawns and falls stay in the same run; practice runs
aren't kept). The host records them
about ten times a second in the game's own replay format and keeps them in its runs folder, the newest ten across
every track (SetKeep) plus any you pin. Runs are numbered newest first (0 is the latest), so a run's number changes as
new ones come; Id stays the same. Everything here needs host 0.24.0.
Replay¶
string Runs::Replay(int run)
A kept run's replay as the host recorded it: the game's own ghost JSON (locations, elapsedTime, rotations,
velocities, the player's look), "" if it can't be read. For sending a run somewhere (a plugin's own server). The game
writes no ghost file of its own for a local map raced with Tracks::OpenLocal; this is the run's replay there.
Requires host 0.26.0.
Example
if (Runs::Count() > 0 && Runs::IsFinished(0))
string replay = Runs::Replay(0);
SetKeep¶
void Runs::SetKeep(int)
How many runs are kept (1 to 500, 10 until set); the oldest go first. Pinned runs don't count.
Example
Runs::SetKeep(25);
Count¶
int Runs::Count()
How many runs are kept now.
Example
for (int i = 0; i < Runs::Count(); i++)
Log::Info(Runs::TrackName(i) + ": " + Runs::Time(i));
Id¶
string Runs::Id(int)
A run's own name, the same for as long as it's kept (its number moves as runs come and go).
Example
string id = Runs::Id(0);
TrackKey¶
string Runs::TrackKey(int)
The track a run was on, as Race::TrackKey gives it.
Example
if (Runs::TrackKey(0) == Race::TrackKey())
Log::Info("the last run was on this track");
TrackName¶
string Runs::TrackName(int)
The name of the track a run was on.
Example
Log::Info(Runs::TrackName(0));
Time¶
double Runs::Time(int)
How long a run lasted, in seconds: its finish time for a finished run.
Example
double t = Runs::Time(0);
IsFinished¶
bool Runs::IsFinished(int)
Whether a run reached the finish.
Example
if (Runs::IsFinished(0))
Log::Info("finished in " + Runs::Time(0));
Age¶
double Runs::Age(int)
Seconds since a run ended.
Example
if (Runs::Age(0) < 60)
Log::Info("a run in the last minute");
IsPinned¶
bool Runs::IsPinned(int)
Whether a run is pinned: kept whatever comes after it.
Example
bool keep = Runs::IsPinned(0);
SetPinned¶
void Runs::SetPinned(int, bool)
Pins a run (kept whatever comes after it, not counted toward SetKeep) or unpins it, which can let the oldest go.
Example
Runs::SetPinned(0, true);
Elapsed¶
double Runs::Elapsed()
Seconds since the start of the run going on now, by the race's own clock; -1 without one.
Example
double now = Runs::Elapsed();
Ball¶
int Runs::Ball(int)
A ball for a run, as Ghosts::PlayerBall makes one for a ghost: your own ball in your skin, see-through. Returns a
Draw id, or 0. Move it with PlaceBall.
Example
int ball = Runs::Ball(0);
PlaceBall¶
bool Runs::PlaceBall(int id, int run, double time)
Puts a ball from Ball where that run was at time seconds into it, turning the way it turned. False if the run is
gone or the ball isn't one.
Example
Runs::PlaceBall(ball, 0, Runs::Elapsed());