RigsofRods
Soft-body Physics Simulation
races.as.h
Go to the documentation of this file.
1 
7 namespace Script2Script {
8 
29 funcdef void RACE_EVENT_CALLBACK(dictionary@);
30 
35 void raceEvent(int trigger_type, string inst, string box, int nodeid);
36 
41 void raceCancelPointHandler(int trigger_type, string inst, string box, int nodeid);
42 
43 
56 {
57 public:
58  int raceCount;
60  int currentLap;
61  int truckNum;
63 
65  bool showTimeDiff;
66  bool showBestLap;
67  bool showBestRace;
68  bool submitScore;
70  bool silentMode;
74 
77  int state;
79  double raceStartTime;
80  double lapStartTime;
85 
86 
87 // public constants
90  int LAPS_One;
91 
96 
100 
102 
103 private:
105  dictionary callbacks;
106 
107 private:
108 
114  void raceEvent(int trigger_type, string inst, string box, int nodeid);
115 
121  string formatTime(double seconds);
122 
127  void finishCurrentRace();
128 
132  void advanceLap();
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 
143 public:
144 
149  racesManager();
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 
242  int addNewEmptyRace();
243 
255  int getNewRaceID();
256 
276  void setCallback(string event, RACE_EVENT_CALLBACK @func);
277 
283  RACE_EVENT_CALLBACK@ getCallback(string event);
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 
352  void cancelCurrentRace();
353 
359  bool raceCompleted(int raceID);
360 
365  int getCurrentRaceID();
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 
481  void recalcArrow();
482 
489  void setupArrow(int position);
490 
494  void removeArrow();
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 
550  void resetEventCallback();
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;
585  double bestLapTime;
586  double bestRaceTime;
587  int laps;
591  int startNum;
592  int[] chpInstances; // needed to be able to remove races
593  bool locked;
594  bool completed;
596  string raceVersion;
597  bool isBuilt;
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
Script2Script::raceBuilder::checkpoints
double[][][] checkpoints
Definition: races.as.h:581
Script2Script::racesManager::LAPS_NoLaps
int LAPS_NoLaps
This race has a seperate start line and finish line.
Definition: races.as.h:89
Script2Script::raceBuilder::getRealInstanceCount
uint getRealInstanceCount(int chpNum)
Script2Script::racesManager::setBestRaceTime
void setBestRaceTime(int raceID, double time)
Sets a best race time.
Script2Script::racesManager::raceEvent
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...
Script2Script::racesManager::raceManagerVersion
string raceManagerVersion
the version of the raceManager
Definition: races.as.h:84
Script2Script::racesManager::raceCompleted
bool raceCompleted(int raceID)
Is a certain race completed?
Script2Script::racesManager::advanceCheckpoint
void advanceCheckpoint(int raceID)
Advances a checkpoint.
Script2Script::racesManager::racesManager
racesManager()
The constructor This initializes everything.
Script2Script::raceBuilder::chpInstances
int[] chpInstances
Definition: races.as.h:592
Script2Script::racesManager::advanceLap
void advanceLap()
Advances a lap.
Script2Script::racesManager::ACTION_SuspendRace
int ACTION_SuspendRace
Not used.
Definition: races.as.h:93
Script2Script::racesManager::addRace
int addRace(string raceName, double[][] checkpoints, int laps, string objName_checkpoint, string objName_start, string objName_finish)
Adds a race to the terrain.
Script2Script::racesManager::addCheckpointList
void addCheckpointList(int raceID, uint startNumber, string objName, double[][] coords)
Adds a list of checkpoints to a race.
Script2Script::raceBuilder::locked
bool locked
Definition: races.as.h:593
Script2Script::racesManager::addPenaltySeconds
bool addPenaltySeconds(int seconds)
Add an amount of penalty time to the current race.
Script2Script::racesManager::ARROW_AUTO
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
Script2Script::raceCancelPointHandler
void raceCancelPointHandler(int trigger_type, string inst, string box, int nodeid)
called when the user drives through a cancel point
Script2Script::racesManager::getRaceIDbyName
int getRaceIDbyName(string raceName_in)
Returns the race ID of a race name.
Script2Script::raceBuilder::deleteCheckpoint
void deleteCheckpoint(int number)
Script2Script::raceBuilder::raceBuilderVersion
string raceBuilderVersion
Definition: races.as.h:600
Script2Script::raceBuilder::objNames
array< array< string > > objNames
Definition: races.as.h:582
Script2Script::raceBuilder::unhide
void unhide()
Script2Script::raceBuilder::finishNum
int finishNum
Definition: races.as.h:590
Script2Script::racesManager::setupArrow
void setupArrow(int position)
Make the directional arrow point to a certain checkpoint of the current race.
Script2Script::racesManager::raceCancelPointHandler
void raceCancelPointHandler(int trigger_type, string inst, string box, int nodeid)
event handler for cancel points
Script2Script::raceBuilder::loadRace
void loadRace(Script2Game::LocalStorage@ d)
Script2Script::racesManager::STATE_Waiting
int STATE_Waiting
A race is suspended, and we're waiting until the race continues.
Definition: races.as.h:98
Script2Script::racesManager::resetEventCallback
void resetEventCallback()
Resets the race event callback.
Script2Script::racesManager::abortOnVehicleExit
bool abortOnVehicleExit
if true: if the user exits his vehicle, the race will be aborted. (default=false)
Definition: races.as.h:72
Script2Script::RACE_EVENT_CALLBACK
funcdef void RACE_EVENT_CALLBACK(dictionary@)
A function signature for the callback pointers.
Script2Script::racesManager::raceList
private raceBuilder[] raceList
Definition: races.as.h:104
Script2Script::raceBuilder::raceBuilder
raceBuilder(int id)
Script2Script::racesManager::formatTime
string formatTime(double seconds)
Formats the time.
Script2Script::raceBuilder::isLocked
bool isLocked()
Script2Script::racesManager::addRaceTime
void addRaceTime(int raceID, double time, bool &out newBestRace)
Script2Script::racesManager::LAPS_Unlimited
int LAPS_Unlimited
Keep looping the race for an unlimited time.
Definition: races.as.h:88
Script2Script::racesManager::lockRace
void lockRace(int raceID)
Locks a race.
Script2Script::raceBuilder::raceName
string raceName
Definition: races.as.h:580
Script2Script::racesManager::loadRace
void loadRace(int raceID)
Loads a race.
Script2Script::racesManager::showCheckPointInfoWhenNotInRace
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
Script2Script::racesManager::raceStartTime
double raceStartTime
Definition: races.as.h:79
Script2Script::racesManager::lapStartTime
double lapStartTime
Definition: races.as.h:80
Script2Script::raceBuilder::getPreviousCheckpointNum
int getPreviousCheckpointNum(int lastCheckpoint)
Script2Script::racesManager::addCancelPoint
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.
Script2Script::racesManager::addNewEmptyRace
int addNewEmptyRace()
Add a new empty race (advanced users only!)
Script2Script::racesManager::cancelPointCount
int cancelPointCount
Definition: races.as.h:78
Script2Script::racesManager::setBestLapTime
void setBestLapTime(int raceID, double time)
Sets a best lap time.
Script2Script::racesManager::silentMode
bool silentMode
if true: No flashmessages will be shown. (default=false)
Definition: races.as.h:70
Script2Script::raceBuilder::awaitingRecycling
bool awaitingRecycling
Definition: races.as.h:598
Script2Script::raceEvent
void raceEvent(int trigger_type, string inst, string box, int nodeid)
called when the user drives through a checkpoint
Script2Script::raceBuilder::hide
void hide()
Script2Script::racesManager::arrowMethod
int arrowMethod
What checkpoint instance should the directional arrow point to. (default=ARROW_AUTO=point to the same...
Definition: races.as.h:73
Script2Script::racesManager::addCheckpoint
void addCheckpoint(int raceID, int number, string objName, double[] coords)
Adds a checkpoint to a race.
Script2Script::raceBuilder::completed
bool completed
Definition: races.as.h:594
Script2Script::racesManager::addLapTime
void addLapTime(int raceID, double time, bool &out newBestLap)
Script2Script::raceBuilder::saveRace
void saveRace(Script2Game::LocalStorage@ d)
Script2Script::racesManager::eventCallback
void eventCallback(int eventnum, int value)
This should be called from within your RoR eventCallback function.
Script2Script::racesManager::STATE_NotInRace
int STATE_NotInRace
We're not racing at the moment.
Definition: races.as.h:97
Script2Script::racesManager::setRaceName
void setRaceName(int raceID, string raceName)
Sets the name for a race.
Script2Script::racesManager::showBestLap
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
Script2Script::racesManager::obligatedFinish
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
Script2Script::racesManager::lastCheckpoint
int lastCheckpoint
The number of the last passed checkpoint.
Definition: races.as.h:62
Script2Script::racesManager::setLaps
void setLaps(int raceID, int laps)
Sets the amount of laps for a race.
Script2Script::racesManager::getBestLapTime
double getBestLapTime(int raceID)
Gets the best lap time of a certain race.
Script2Script::raceBuilder::id
int id
Definition: races.as.h:584
Script2Script::raceBuilder::setLaps
void setLaps(int laps_in)
Script2Script::racesManager::callbacks
dictionary callbacks
Definition: races.as.h:105
Script2Script::raceBuilder
This class manages a race (singular!) You should only use this directly if the racesManager doesn't s...
Definition: races.as.h:578
Script2Script::racesManager::finalize
void finalize(int raceID)
Finalizes your (advanced) race.
Script2Script::raceBuilder::getNextCheckpointNum
int getNextCheckpointNum(int lastCheckpoint)
Script2Script::raceBuilder::setVersion
void setVersion(const string &in version)
Script2Script::racesManager::deleteCheckPoint
void deleteCheckPoint(int raceID, int number, int instance)
This deletes a checkpoint from a race.
Script2Script::racesManager::deleteRace
void deleteRace(int raceID)
Deletes a race.
Script2Script::raceBuilder::checkPointsCount
int checkPointsCount
Definition: races.as.h:583
Script2Script::racesManager::getBestRaceTime
double getBestRaceTime(int raceID)
Gets the best race time of a certain race.
Script2Script::racesManager::removeArrow
void removeArrow()
This hides the directional arrow.
Script2Script::racesManager::penaltyGiven
bool penaltyGiven
Definition: races.as.h:75
Script2Script::racesManager::STATE_Racing
int STATE_Racing
We're in the middle of a race :D.
Definition: races.as.h:99
Script2Script::racesManager::ACTION_DoNothing
int ACTION_DoNothing
Not used.
Definition: races.as.h:92
Script2Script::racesManager::setPenaltyTime
void setPenaltyTime(int raceID, int seconds)
This sets the penalty time of a race.
Script2Script
Pseudo-namespace; it doesn't exist in code or script runtime, only in this documentation.
Definition: races.as.h:7
Script2Script::racesManager::submitScore
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
Script2Script::racesManager::getNewRaceID
int getNewRaceID()
Creates a new free race ID.
Script2Script::racesManager::removeCallback
void removeCallback(string event)
Remove a callback function.
Script2Script::racesManager::cancelCurrentRace
void cancelCurrentRace()
Aborts the current race.
Script2Script::racesManager::showTimeDiff
bool showTimeDiff
if true: Show + or - [best time minus current time] when passing a checkpoint. (default=true)
Definition: races.as.h:65
Script2Script::raceBuilder::addCheckpoint
void addCheckpoint(int number, const string &in objName, const double[] &in v)
Script2Script::racesManager::getPenaltyTime
int getPenaltyTime(int raceID)
This returns the penalty time setting of a race.
Script2Script::racesManager::getRace
raceBuilder getRace(int raceID)
Gets the raceBuilder object of a race.
Script2Script::racesManager::unlockRace
void unlockRace(int raceID)
Unlocks a race.
Script2Script::racesManager::ACTION_RestartRace
int ACTION_RestartRace
Not used.
Definition: races.as.h:95
Script2Script::racesManager::getCurrentRaceID
int getCurrentRaceID()
Gets the ID of the current race.
Script2Script::racesManager::raceCount
int raceCount
the raceID+1 of the last race.
Definition: races.as.h:58
Script2Script::raceBuilder::lastTimeTillPoint
double[] lastTimeTillPoint
Definition: races.as.h:589
Script2Script::racesManager::setStartNumber
void setStartNumber(int raceID, int startNum)
This allows you to change the startNumber of a race.
Script2Script::racesManager::LAPS_One
int LAPS_One
This race consist of 1 lap, and the start and finish line are the same object.
Definition: races.as.h:90
Script2Script::racesManager::currentLap
int currentLap
the number of the current lap. (starts from 0)
Definition: races.as.h:60
instance
or anywhere else will not be considered a but parsed as regular data ! Each line is treated as values separated by separators Possible i e animators Multiline description Single instance
Definition: ReadMe.txt:53
Script2Script::raceBuilder::penaltyTime
int penaltyTime
Definition: races.as.h:595
Script2Script::racesManager::saveRaces
void saveRaces()
Saves all races.
Script2Script::racesManager::ACTION_StopRace
int ACTION_StopRace
Not used.
Definition: races.as.h:94
Script2Script::racesManager::hideRace
void hideRace(int raceID)
This hides your race.
Script2Script::racesManager::getCallback
RACE_EVENT_CALLBACK getCallback(string event)
Gets a callback funciton.
Script2Script::racesManager::setVersion
void setVersion(int raceID, string version)
This sets the version of your race.
Script2Script::raceBuilder::startNum
int startNum
Definition: races.as.h:591
Script2Script::racesManager::lastRaceEventTime
double lastRaceEventTime
Definition: races.as.h:83
Script2Script::racesManager::recalcArrow
void recalcArrow()
Recalculates where the arrow should point to.
Script2Script::raceBuilder::bestRaceTime
double bestRaceTime
Definition: races.as.h:586
Script2Script::raceBuilder::raceVersion
string raceVersion
Definition: races.as.h:596
Script2Script::racesManager::saveRace
void saveRace(int raceID)
Saves a race.
Script2Script::racesManager
This class allows you to organize races.
Definition: races.as.h:55
Script2Script::racesManager::getLaps
int getLaps(int raceID)
Gets the amount of laps for a race.
Script2Script::raceBuilder::isBuilt
bool isBuilt
Definition: races.as.h:597
Script2Script::racesManager::startRace
void startRace(int raceID)
Starts a race.
Script2Script::racesManager::actionOnTruckExit
int actionOnTruckExit
Definition: races.as.h:76
Script2Script::racesManager::finishCurrentRace
void finishCurrentRace()
Finishes a race.
Script2Script::racesManager::lastCheckpointInstance
string lastCheckpointInstance
Definition: races.as.h:81
Script2Script::racesManager::unhideRace
void unhideRace(int raceID)
This shows your race again, after it was hidden.
Script2Script::raceBuilder::addChpCoordinates
void addChpCoordinates(double[][] checkpoints_in, const string &in objName_checkpoint, const string &in objName_start, const string &in objName_finish, uint startNumber)
Script2Script::racesManager::truckNum
int truckNum
The number of the (last) used truck in the race.
Definition: races.as.h:61
Script2Script::racesManager::setCallback
void setCallback(string event, RACE_EVENT_CALLBACK @func)
Adds a callback funciton.
Script2Script::raceBuilder::checkpointExists
bool checkpointExists(int chpNum, int instance)
Script2Script::raceBuilder::laps
int laps
Definition: races.as.h:587
Script2Script::racesManager::lastRaceEventInstance
string lastRaceEventInstance
Definition: races.as.h:82
Script2Script::raceBuilder::bestTimeTillPoint
double[] bestTimeTillPoint
Definition: races.as.h:588
Script2Script::raceBuilder::bestLapTime
double bestLapTime
Definition: races.as.h:585
Script2Script::raceBuilder::hidden
bool hidden
Definition: races.as.h:599
Script2Script::racesManager::state
int state
In which state are we?
Definition: races.as.h:77
Script2Script::raceBuilder::destroy
void destroy()
this function removes all checkpoints again
Script2Script::racesManager::allowVehicleChanging
bool allowVehicleChanging
if false: if the user changes vehicle, the race will be aborted. (default=false)
Definition: races.as.h:71
Script2Script::racesManager::currentRace
int currentRace
the ID of the current race. (-1 is there's no race running at the moment)
Definition: races.as.h:59
Script2Script::racesManager::showBestRace
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