Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
races.as.h
Go to the documentation of this file.
1
7namespace Script2Script {
8
29funcdef void RACE_EVENT_CALLBACK(dictionary@);
30
35void raceEvent(int trigger_type, string inst, string box, int nodeid);
36
41void raceCancelPointHandler(int trigger_type, string inst, string box, int nodeid);
42
43
56{
57public:
63
74
77 int state;
85
86
87// public constants
91
96
100
102
103private:
105 dictionary callbacks;
106
107private:
108
114 void raceEvent(int trigger_type, string inst, string box, int nodeid);
115
121 string formatTime(double seconds);
122
128
133
134 void addLapTime(int raceID, double time, bool &out newBestLap);
135
136 void addRaceTime(int raceID, double time, bool &out newBestRace);
137
141 void raceCancelPointHandler(int trigger_type, string inst, string box, int nodeid);
142
143public:
144
150
177 int addRace(string raceName, double[][] checkpoints, int laps, string objName_checkpoint, string objName_start, string objName_finish);
178
188 int addRace(string raceName, double[][] checkpoints, int laps, string objName_checkpoint, string objName_start_finish);
189
198 int addRace(string raceName, double[][] checkpoints, int laps, string objName_checkpoint);
199
207 int addRace(string raceName, double[][] checkpoints, int laps);
208
215 int addRace(string raceName, double[][] checkpoints);
216
243
256
276 void setCallback(string event, RACE_EVENT_CALLBACK @func);
277
284
289 void removeCallback(string event);
290
295 void startRace(int raceID);
296
301 void advanceCheckpoint(int raceID);
302
308 void setBestLapTime(int raceID, double time);
309
315 void setBestRaceTime(int raceID, double time);
316
322 void eventCallback(int eventnum, int value);
323
328 void unlockRace(int raceID);
329
334 void lockRace(int raceID);
335
340 void deleteRace(int raceID);
341
347 int getRaceIDbyName(string raceName_in);
348
353
359 bool raceCompleted(int raceID);
360
366
372 double getBestLapTime(int raceID);
373
379 double getBestRaceTime(int raceID);
380
386 bool addPenaltySeconds(int seconds);
387
393 void setLaps(int raceID, int laps);
394
400 void setRaceName(int raceID, string raceName);
401
407 int getLaps(int raceID);
408
415 raceBuilder@ getRace(int raceID);
416
432 void addCheckpoint(int raceID, int number, string objName, double[] coords);
433
447 void addCheckpointList(int raceID, uint startNumber, string objName, double[][] coords);
448
465 void deleteCheckPoint(int raceID, int number, int instance);
466
475 void addCancelPoint(int raceID, string objName, double[] v, RACE_EVENT_CALLBACK @callback);
476
482
489 void setupArrow(int position);
490
495
501 void setPenaltyTime(int raceID, int seconds);
502
508 int getPenaltyTime(int raceID);
509
516 void setVersion(int raceID, string version);
517
523 void hideRace(int raceID);
524
529 void unhideRace(int raceID);
530
541 void setStartNumber(int raceID, int startNum);
542
551
555 void finalize(int raceID);
556
560 void saveRaces();
561
566 void saveRace(int raceID);
567
572 void loadRace(int raceID);
573};
574
579{
580 string raceName;
581 double[][][] checkpoints;
582 array<array<string>> objNames;
584 int id;
587 int laps;
592 int[] chpInstances; // needed to be able to remove races
593 bool locked;
599 bool hidden;
601
602 raceBuilder(int id);
603 void setVersion(const string &in version);
604 void addChpCoordinates(double[][] checkpoints_in, const string &in objName_checkpoint, const string &in objName_start, const string &in objName_finish, uint startNumber);
605 int getNextCheckpointNum(int lastCheckpoint);
606 int getPreviousCheckpointNum(int lastCheckpoint);
607 void addCheckpoint(int number, const string &in objName, const double[] &in v);
608 void deleteCheckpoint(int number);
609 uint getRealInstanceCount(int chpNum);
610 bool checkpointExists(int chpNum, int instance);
611 void deleteCheckpoint(int number, int instance);
612 void destroy();
613 void hide();
614 void unhide();
615 void setLaps(int laps_in);
616 bool isLocked();
617 void saveRace(Script2Game::LocalStorage@ d);
618 void loadRace(Script2Game::LocalStorage@ d);
619};
620
//addtogroup Script2Script //addtogroup ScriptSideAPIs
623
624} // namespace Script2Script
This class manages a race (singular!) You should only use this directly if the racesManager doesn't s...
Definition races.as.h:579
void destroy()
this function removes all checkpoints again
void loadRace(Script2Game::LocalStorage@ d)
void saveRace(Script2Game::LocalStorage@ d)
void deleteCheckpoint(int number, int instance)
void setVersion(const string &in version)
void deleteCheckpoint(int number)
array< array< string > > objNames
Definition races.as.h:582
void addCheckpoint(int number, const string &in objName, const double[] &in v)
void setLaps(int laps_in)
int getNextCheckpointNum(int lastCheckpoint)
void addChpCoordinates(double[][] checkpoints_in, const string &in objName_checkpoint, const string &in objName_start, const string &in objName_finish, uint startNumber)
uint getRealInstanceCount(int chpNum)
bool checkpointExists(int chpNum, int instance)
int getPreviousCheckpointNum(int lastCheckpoint)
This class allows you to organize races.
Definition races.as.h:56
void addRaceTime(int raceID, double time, bool &out newBestRace)
void deleteRace(int raceID)
Deletes a race.
double getBestRaceTime(int raceID)
Gets the best race time of a certain race.
int getRaceIDbyName(string raceName_in)
Returns the race ID of a race name.
void unhideRace(int raceID)
This shows your race again, after it was hidden.
bool addPenaltySeconds(int seconds)
Add an amount of penalty time to the current race.
void unlockRace(int raceID)
Unlocks a race.
raceBuilder getRace(int raceID)
Gets the raceBuilder object of a race.
int getPenaltyTime(int raceID)
This returns the penalty time setting of a race.
int STATE_Racing
We're in the middle of a race :D.
Definition races.as.h:99
void advanceLap()
Advances a lap.
int ARROW_AUTO
This arrow method will always point to the checkpoint instance that comes closest to the previous one...
Definition races.as.h:101
int ACTION_RestartRace
Not used.
Definition races.as.h:95
int addRace(string raceName, double[][] checkpoints, int laps)
Add a race to the terrain, using the default checkpoint objects.
int getCurrentRaceID()
Gets the ID of the current race.
int addRace(string raceName, double[][] checkpoints)
Add a not-looping race to the terrain, using the default checkpoint objects.
bool raceCompleted(int raceID)
Is a certain race completed?
string raceManagerVersion
the version of the raceManager
Definition races.as.h:84
string formatTime(double seconds)
Formats the time.
void setPenaltyTime(int raceID, int seconds)
This sets the penalty time of a race.
int addRace(string raceName, double[][] checkpoints, int laps, string objName_checkpoint, string objName_start, string objName_finish)
Adds a race to the terrain.
void addCheckpointList(int raceID, uint startNumber, string objName, double[][] coords)
Adds a list of checkpoints to a race.
bool allowVehicleChanging
if false: if the user changes vehicle, the race will be aborted. (default=false)
Definition races.as.h:71
void setBestLapTime(int raceID, double time)
Sets a best lap time.
bool showTimeDiff
if true: Show + or - [best time minus current time] when passing a checkpoint. (default=true)
Definition races.as.h:65
int arrowMethod
What checkpoint instance should the directional arrow point to. (default=ARROW_AUTO=point to the same...
Definition races.as.h:73
void finishCurrentRace()
Finishes a race.
int currentLap
the number of the current lap. (starts from 0)
Definition races.as.h:60
int lastCheckpoint
The number of the last passed checkpoint.
Definition races.as.h:62
void loadRace(int raceID)
Loads a race.
void eventCallback(int eventnum, int value)
This should be called from within your RoR eventCallback function.
racesManager()
The constructor This initializes everything.
int raceCount
the raceID+1 of the last race.
Definition races.as.h:58
void setupArrow(int position)
Make the directional arrow point to a certain checkpoint of the current race.
int LAPS_One
This race consist of 1 lap, and the start and finish line are the same object.
Definition races.as.h:90
void lockRace(int raceID)
Locks a race.
void cancelCurrentRace()
Aborts the current race.
void setCallback(string event, RACE_EVENT_CALLBACK @func)
Adds a callback funciton.
bool showCheckPointInfoWhenNotInRace
if true: if the user drives through a checkpoint of a race that isn't running, a message will be show...
Definition races.as.h:69
bool abortOnVehicleExit
if true: if the user exits his vehicle, the race will be aborted. (default=false)
Definition races.as.h:72
void setLaps(int raceID, int laps)
Sets the amount of laps for a race.
void startRace(int raceID)
Starts a race.
int STATE_NotInRace
We're not racing at the moment.
Definition races.as.h:97
RACE_EVENT_CALLBACK getCallback(string event)
Gets a callback funciton.
void addCancelPoint(int raceID, string objName, double[] v, RACE_EVENT_CALLBACK @callback)
This allows you to add an object with event boxes that will cause the race to be aborted.
bool obligatedFinish
if true: if you drive through the start checkpoint of another race, while racing, it will be ignored....
Definition races.as.h:64
void saveRace(int raceID)
Saves a race.
int LAPS_Unlimited
Keep looping the race for an unlimited time.
Definition races.as.h:88
void removeCallback(string event)
Remove a callback function.
bool showBestLap
if true: If a race is started or a new best lap is set, the best lap will be shown....
Definition races.as.h:66
int LAPS_NoLaps
This race has a seperate start line and finish line.
Definition races.as.h:89
int state
In which state are we?
Definition races.as.h:77
void deleteCheckPoint(int raceID, int number, int instance)
This deletes a checkpoint from a race.
int ACTION_StopRace
Not used.
Definition races.as.h:94
void raceCancelPointHandler(int trigger_type, string inst, string box, int nodeid)
event handler for cancel points
void setBestRaceTime(int raceID, double time)
Sets a best race time.
double getBestLapTime(int raceID)
Gets the best lap time of a certain race.
void saveRaces()
Saves all races.
void setStartNumber(int raceID, int startNum)
This allows you to change the startNumber of a race.
int ACTION_SuspendRace
Not used.
Definition races.as.h:93
int addRace(string raceName, double[][] checkpoints, int laps, string objName_checkpoint)
Add a race to the terrain.
void addLapTime(int raceID, double time, bool &out newBestLap)
int getNewRaceID()
Creates a new free race ID.
int STATE_Waiting
A race is suspended, and we're waiting until the race continues.
Definition races.as.h:98
void resetEventCallback()
Resets the race event callback.
int truckNum
The number of the (last) used truck in the race.
Definition races.as.h:61
void setVersion(int raceID, string version)
This sets the version of your race.
void hideRace(int raceID)
This hides your race.
int addRace(string raceName, double[][] checkpoints, int laps, string objName_checkpoint, string objName_start_finish)
Add a race to the terrain.
void addCheckpoint(int raceID, int number, string objName, double[] coords)
Adds a checkpoint to a race.
void raceEvent(int trigger_type, string inst, string box, int nodeid)
This will get called when a truck is at a checkpoint You shouldn't call this manually (use the "Check...
bool showBestRace
if true: If a race is started or a new best race is set, the best race will be shown....
Definition races.as.h:67
void setRaceName(int raceID, string raceName)
Sets the name for a race.
int ACTION_DoNothing
Not used.
Definition races.as.h:92
int currentRace
the ID of the current race. (-1 is there's no race running at the moment)
Definition races.as.h:59
void advanceCheckpoint(int raceID)
Advances a checkpoint.
void recalcArrow()
Recalculates where the arrow should point to.
bool submitScore
if true: If the user has a new best lap or new best race, this is submitted to the master server....
Definition races.as.h:68
void removeArrow()
This hides the directional arrow.
int addNewEmptyRace()
Add a new empty race (advanced users only!)
bool silentMode
if true: No flashmessages will be shown. (default=false)
Definition races.as.h:70
void finalize(int raceID)
Finalizes your (advanced) race.
int getLaps(int raceID)
Gets the amount of laps for a race.
void raceCancelPointHandler(int trigger_type, string inst, string box, int nodeid)
called when the user drives through a cancel point
funcdef void RACE_EVENT_CALLBACK(dictionary@)
A function signature for the callback pointers.
void raceEvent(int trigger_type, string inst, string box, int nodeid)
called when the user drives through a checkpoint
Pseudo-namespace; it doesn't exist in code or script runtime, only in this documentation.
Definition races.as.h:7