RigsofRods
Soft-body Physics Simulation
|
This class allows you to organize races. More...
#include <races.as.h>
Public Member Functions | |
racesManager () | |
The constructor This initializes everything. More... | |
int | addRace (string raceName, double[][] checkpoints, int laps, string objName_checkpoint, string objName_start, string objName_finish) |
Adds a race to the terrain. More... | |
int | addRace (string raceName, double[][] checkpoints, int laps, string objName_checkpoint, string objName_start_finish) |
Add a race to the terrain. More... | |
int | addRace (string raceName, double[][] checkpoints, int laps, string objName_checkpoint) |
Add a race to the terrain. More... | |
int | addRace (string raceName, double[][] checkpoints, int laps) |
Add a race to the terrain, using the default checkpoint objects. More... | |
int | addRace (string raceName, double[][] checkpoints) |
Add a not-looping race to the terrain, using the default checkpoint objects. More... | |
int | addNewEmptyRace () |
Add a new empty race (advanced users only!) More... | |
int | getNewRaceID () |
Creates a new free race ID. More... | |
void | setCallback (string event, RACE_EVENT_CALLBACK @func) |
Adds a callback funciton. More... | |
RACE_EVENT_CALLBACK | getCallback (string event) |
Gets a callback funciton. More... | |
void | removeCallback (string event) |
Remove a callback function. More... | |
void | startRace (int raceID) |
Starts a race. More... | |
void | advanceCheckpoint (int raceID) |
Advances a checkpoint. More... | |
void | setBestLapTime (int raceID, double time) |
Sets a best lap time. More... | |
void | setBestRaceTime (int raceID, double time) |
Sets a best race time. More... | |
void | eventCallback (int eventnum, int value) |
This should be called from within your RoR eventCallback function. More... | |
void | unlockRace (int raceID) |
Unlocks a race. More... | |
void | lockRace (int raceID) |
Locks a race. More... | |
void | deleteRace (int raceID) |
Deletes a race. More... | |
int | getRaceIDbyName (string raceName_in) |
Returns the race ID of a race name. More... | |
void | cancelCurrentRace () |
Aborts the current race. More... | |
bool | raceCompleted (int raceID) |
Is a certain race completed? More... | |
int | getCurrentRaceID () |
Gets the ID of the current race. More... | |
double | getBestLapTime (int raceID) |
Gets the best lap time of a certain race. More... | |
double | getBestRaceTime (int raceID) |
Gets the best race time of a certain race. More... | |
bool | addPenaltySeconds (int seconds) |
Add an amount of penalty time to the current race. More... | |
void | setLaps (int raceID, int laps) |
Sets the amount of laps for a race. More... | |
void | setRaceName (int raceID, string raceName) |
Sets the name for a race. More... | |
int | getLaps (int raceID) |
Gets the amount of laps for a race. More... | |
raceBuilder | getRace (int raceID) |
Gets the raceBuilder object of a race. More... | |
void | addCheckpoint (int raceID, int number, string objName, double[] coords) |
Adds a checkpoint to a race. More... | |
void | addCheckpointList (int raceID, uint startNumber, string objName, double[][] coords) |
Adds a list of checkpoints to a race. More... | |
void | deleteCheckPoint (int raceID, int number, int instance) |
This deletes a checkpoint from a race. More... | |
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. More... | |
void | recalcArrow () |
Recalculates where the arrow should point to. More... | |
void | setupArrow (int position) |
Make the directional arrow point to a certain checkpoint of the current race. More... | |
void | removeArrow () |
This hides the directional arrow. More... | |
void | setPenaltyTime (int raceID, int seconds) |
This sets the penalty time of a race. More... | |
int | getPenaltyTime (int raceID) |
This returns the penalty time setting of a race. More... | |
void | setVersion (int raceID, string version) |
This sets the version of your race. More... | |
void | hideRace (int raceID) |
This hides your race. More... | |
void | unhideRace (int raceID) |
This shows your race again, after it was hidden. More... | |
void | setStartNumber (int raceID, int startNum) |
This allows you to change the startNumber of a race. More... | |
void | resetEventCallback () |
Resets the race event callback. More... | |
void | finalize (int raceID) |
Finalizes your (advanced) race. More... | |
void | saveRaces () |
Saves all races. More... | |
void | saveRace (int raceID) |
Saves a race. More... | |
void | loadRace (int raceID) |
Loads a race. More... | |
Data Fields | |
int | raceCount |
the raceID+1 of the last race. More... | |
int | currentRace |
the ID of the current race. (-1 is there's no race running at the moment) More... | |
int | currentLap |
the number of the current lap. (starts from 0) More... | |
int | truckNum |
The number of the (last) used truck in the race. More... | |
int | lastCheckpoint |
The number of the last passed checkpoint. More... | |
bool | obligatedFinish |
if true: if you drive through the start checkpoint of another race, while racing, it will be ignored. (default=false) More... | |
bool | showTimeDiff |
if true: Show + or - [best time minus current time] when passing a checkpoint. (default=true) More... | |
bool | showBestLap |
if true: If a race is started or a new best lap is set, the best lap will be shown. (default=true) More... | |
bool | showBestRace |
if true: If a race is started or a new best race is set, the best race will be shown. (default=true) More... | |
bool | submitScore |
if true: If the user has a new best lap or new best race, this is submitted to the master server. (default=true) More... | |
bool | showCheckPointInfoWhenNotInRace |
if true: if the user drives through a checkpoint of a race that isn't running, a message will be shown, saying "this is checkpoint xx of race myRaceName". (default=false) More... | |
bool | silentMode |
if true: No flashmessages will be shown. (default=false) More... | |
bool | allowVehicleChanging |
if false: if the user changes vehicle, the race will be aborted. (default=false) More... | |
bool | abortOnVehicleExit |
if true: if the user exits his vehicle, the race will be aborted. (default=false) More... | |
int | arrowMethod |
What checkpoint instance should the directional arrow point to. (default=ARROW_AUTO=point to the same instance as last checkpoint) More... | |
bool | penaltyGiven |
int | actionOnTruckExit |
int | state |
In which state are we? More... | |
int | cancelPointCount |
double | raceStartTime |
double | lapStartTime |
string | lastCheckpointInstance |
string | lastRaceEventInstance |
double | lastRaceEventTime |
string | raceManagerVersion |
the version of the raceManager More... | |
int | LAPS_Unlimited |
Keep looping the race for an unlimited time. More... | |
int | LAPS_NoLaps |
This race has a seperate start line and finish line. More... | |
int | LAPS_One |
This race consist of 1 lap, and the start and finish line are the same object. More... | |
int | ACTION_DoNothing |
Not used. More... | |
int | ACTION_SuspendRace |
Not used. More... | |
int | ACTION_StopRace |
Not used. More... | |
int | ACTION_RestartRace |
Not used. More... | |
int | STATE_NotInRace |
We're not racing at the moment. More... | |
int | STATE_Waiting |
A race is suspended, and we're waiting until the race continues. More... | |
int | STATE_Racing |
We're in the middle of a race :D. More... | |
int | ARROW_AUTO |
This arrow method will always point to the checkpoint instance that comes closest to the previous one. More... | |
Private Member Functions | |
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 "Checkpoint" callback instead) More... | |
string | formatTime (double seconds) |
Formats the time. More... | |
void | finishCurrentRace () |
Finishes a race. More... | |
void | advanceLap () |
Advances a lap. More... | |
void | addLapTime (int raceID, double time, bool &out newBestLap) |
void | addRaceTime (int raceID, double time, bool &out newBestRace) |
void | raceCancelPointHandler (int trigger_type, string inst, string box, int nodeid) |
event handler for cancel points More... | |
Private Attributes | |
private raceBuilder[] | raceList |
dictionary | callbacks |
This class allows you to organize races.
This class will handle all the race logic for you.
Definition at line 55 of file races.as.h.
Script2Script::racesManager::racesManager | ( | ) |
The constructor This initializes everything.
void Script2Script::racesManager::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.
raceID | the ID of the race |
objName | The name of the object (~the name of the odef file, but without the .odef extension) |
v | The position where the cancel point should be |
callback | A callback function that will be called when the race is canceled because of this cancel point. |
void Script2Script::racesManager::addCheckpoint | ( | int | raceID, |
int | number, | ||
string | objName, | ||
double[] | coords | ||
) |
Adds a checkpoint to a race.
This allows you to have duplicate checkpoints (useful to create shortcuts or splitted tracks).
raceID | the ID of the race |
number | The number of the checkpoint in the race. 0 is the start line 1 would be the first checkpoint 2 is the second checkpoint etc. You can have multiple checkpoints for the same number. The user will then be able to choose which checkpoint he takes. |
objName | the name of the object that should be used for the checkpoint |
coords | the coordinate for the race (6 numbers! |
void Script2Script::racesManager::addCheckpointList | ( | int | raceID, |
uint | startNumber, | ||
string | objName, | ||
double | coords[][] | ||
) |
Adds a list of checkpoints to a race.
This allows you to have duplicate checkpoints (useful to create shortcuts or splitted tracks).
raceID | the ID of the race |
startNumber | The number of the first checkpoint that should be added The first checkpoint in the coords list, will be added as number startNumber. The second checkpoint in the coords list, will be added as startNumber+1 etc. You can have multiple checkpoints for the same number. The user will then be able to choose which checkpoint he takes. |
objName | the name of the object that should be used for the checkpoint |
coords | a list of coordinates for the race (6 numbers per coordinate |
|
private |
int Script2Script::racesManager::addNewEmptyRace | ( | ) |
Add a new empty race (advanced users only!)
bool Script2Script::racesManager::addPenaltySeconds | ( | int | seconds | ) |
Add an amount of penalty time to the current race.
seconds | the amount of seconds to add to the time |
int Script2Script::racesManager::addRace | ( | string | raceName, |
double | checkpoints[][] | ||
) |
Add a not-looping race to the terrain, using the default checkpoint objects.
raceName | The name of the race. This needs to be unique for your terrain, and shouldn't contain points. |
checkpoints | An array of coordinates ( a coordinate exists out of 6 numbers: { position.x, position.y, position.z, rotation.x, rotation.y, rotation.z } |
int Script2Script::racesManager::addRace | ( | string | raceName, |
double | checkpoints[][], | ||
int | laps | ||
) |
Add a race to the terrain, using the default checkpoint objects.
raceName | The name of the race. This needs to be unique for your terrain, and shouldn't contain points. |
checkpoints | An array of coordinates ( a coordinate exists out of 6 numbers: { position.x, position.y, position.z, rotation.x, rotation.y, rotation.z } |
laps | The amount of laps. This can be one of the following: LAPS_Unlimited, LAPS_NoLaps, LAPS_One or another number representing the amount of laps (>=1) |
int Script2Script::racesManager::addRace | ( | string | raceName, |
double | checkpoints[][], | ||
int | laps, | ||
string | objName_checkpoint | ||
) |
Add a race to the terrain.
raceName | The name of the race. This needs to be unique for your terrain, and shouldn't contain points. |
checkpoints | An array of coordinates ( a coordinate exists out of 6 numbers: { position.x, position.y, position.z, rotation.x, rotation.y, rotation.z } |
laps | The amount of laps. This can be one of the following: LAPS_Unlimited, LAPS_NoLaps, LAPS_One or another number representing the amount of laps (>=1) |
objName_checkpoint | The name of the object that should be used as checkpoint, start line and finish line |
int Script2Script::racesManager::addRace | ( | string | raceName, |
double | checkpoints[][], | ||
int | laps, | ||
string | objName_checkpoint, | ||
string | objName_start, | ||
string | objName_finish | ||
) |
Adds a race to the terrain.
raceName | The name of the race. This needs to be unique for your terrain, and shouldn't contain points. |
checkpoints | An array of coordinates ( a coordinate exists out of 6 numbers: { position.x, position.y, position.z, rotation.x, rotation.y, rotation.z } |
laps | The amount of laps. This can be one of the following: LAPS_Unlimited, LAPS_NoLaps, LAPS_One or another number representing the amount of laps (>=1) |
objName_checkpoint | The name of the object that should be used as checkpoint |
objName_start | The name of the object that should be used as start line |
objName_finish | The name of the object that should be used as finish |
int Script2Script::racesManager::addRace | ( | string | raceName, |
double | checkpoints[][], | ||
int | laps, | ||
string | objName_checkpoint, | ||
string | objName_start_finish | ||
) |
Add a race to the terrain.
raceName | The name of the race. This needs to be unique for your terrain, and shouldn't contain points. |
checkpoints | An array of coordinates ( a coordinate exists out of 6 numbers: { position.x, position.y, position.z, rotation.x, rotation.y, rotation.z } |
laps | The amount of laps. This can be one of the following: LAPS_Unlimited, LAPS_NoLaps, LAPS_One or another number representing the amount of laps (>=1) |
objName_checkpoint | The name of the object that should be used as checkpoint |
objName_start_finish | The name of the object that should be used as start line and as finish line |
|
private |
void Script2Script::racesManager::advanceCheckpoint | ( | int | raceID | ) |
Advances a checkpoint.
raceID | the ID of the race |
|
private |
Advances a lap.
void Script2Script::racesManager::cancelCurrentRace | ( | ) |
Aborts the current race.
void Script2Script::racesManager::deleteCheckPoint | ( | int | raceID, |
int | number, | ||
int | instance | ||
) |
This deletes a checkpoint from a race.
raceID | the ID of the race |
number | The number of the checkpoint in the race. 0 is the start line 1 would be the first checkpoint 2 is the second checkpoint etc. |
instance | which instance of this checkpoint should be deleted? (you can have multiple checkpoints with the same number. The first added checkpoint for a certain number will have 0 as instance number, the second added checkpoint for a certain number will have 1 as instance.) |
void Script2Script::racesManager::deleteRace | ( | int | raceID | ) |
Deletes a race.
raceID | the ID of the race |
void Script2Script::racesManager::eventCallback | ( | int | eventnum, |
int | value | ||
) |
This should be called from within your RoR eventCallback function.
eventnum | the number of the event |
value | the value of the event |
void Script2Script::racesManager::finalize | ( | int | raceID | ) |
Finalizes your (advanced) race.
|
private |
Finishes a race.
|
private |
Formats the time.
seconds | An amount of seconds |
double Script2Script::racesManager::getBestLapTime | ( | int | raceID | ) |
Gets the best lap time of a certain race.
raceID | the ID of the race |
double Script2Script::racesManager::getBestRaceTime | ( | int | raceID | ) |
Gets the best race time of a certain race.
raceID | the ID of the race |
RACE_EVENT_CALLBACK Script2Script::racesManager::getCallback | ( | string | event | ) |
Gets a callback funciton.
event | The name of the event. |
int Script2Script::racesManager::getCurrentRaceID | ( | ) |
Gets the ID of the current race.
int Script2Script::racesManager::getLaps | ( | int | raceID | ) |
Gets the amount of laps for a race.
raceID | the ID of the race |
int Script2Script::racesManager::getNewRaceID | ( | ) |
Creates a new free race ID.
int Script2Script::racesManager::getPenaltyTime | ( | int | raceID | ) |
This returns the penalty time setting of a race.
raceID | the ID of the race |
raceBuilder Script2Script::racesManager::getRace | ( | int | raceID | ) |
Gets the raceBuilder object of a race.
raceID | the ID of the race |
int Script2Script::racesManager::getRaceIDbyName | ( | string | raceName_in | ) |
Returns the race ID of a race name.
raceName_in | the race name |
void Script2Script::racesManager::hideRace | ( | int | raceID | ) |
void Script2Script::racesManager::loadRace | ( | int | raceID | ) |
Loads a race.
raceID | the ID of the race |
void Script2Script::racesManager::lockRace | ( | int | raceID | ) |
Locks a race.
raceID | the ID of the race |
|
private |
event handler for cancel points
bool Script2Script::racesManager::raceCompleted | ( | int | raceID | ) |
Is a certain race completed?
raceID | the ID of the race |
|
private |
This will get called when a truck is at a checkpoint You shouldn't call this manually (use the "Checkpoint" callback instead)
void Script2Script::racesManager::recalcArrow | ( | ) |
Recalculates where the arrow should point to.
Useful if you changed the arrowMethod variable or if you changed the position of the next checkpoint.
void Script2Script::racesManager::removeArrow | ( | ) |
This hides the directional arrow.
void Script2Script::racesManager::removeCallback | ( | string | event | ) |
void Script2Script::racesManager::resetEventCallback | ( | ) |
Resets the race event callback.
If the user drives through a checkpoint, then the script will only handle the event once, event if the user is in the event box for multiple frames. Sometimes, you may want to reset this, and then, you can call this function.
void Script2Script::racesManager::saveRace | ( | int | raceID | ) |
Saves a race.
raceID | the ID of the race |
void Script2Script::racesManager::saveRaces | ( | ) |
Saves all races.
void Script2Script::racesManager::setBestLapTime | ( | int | raceID, |
double | time | ||
) |
Sets a best lap time.
raceID | the ID of the race |
time | the lap time |
void Script2Script::racesManager::setBestRaceTime | ( | int | raceID, |
double | time | ||
) |
Sets a best race time.
raceID | the ID of the race |
time | the race time |
void Script2Script::racesManager::setCallback | ( | string | event, |
RACE_EVENT_CALLBACK @ | func | ||
) |
Adds a callback funciton.
event | The name of the event. This can only be one of the following:
|
func | A reference to the function |
void Script2Script::racesManager::setLaps | ( | int | raceID, |
int | laps | ||
) |
Sets the amount of laps for a race.
raceID | the ID of the race |
laps | The amount of laps |
void Script2Script::racesManager::setPenaltyTime | ( | int | raceID, |
int | seconds | ||
) |
This sets the penalty time of a race.
raceID | the ID of the race |
seconds | how much penalty time should be set? (in seconds) |
void Script2Script::racesManager::setRaceName | ( | int | raceID, |
string | raceName | ||
) |
Sets the name for a race.
raceID | the ID of the race |
raceName | The name of the race (needs to be unique, and shouldn't contain points) |
void Script2Script::racesManager::setStartNumber | ( | int | raceID, |
int | startNum | ||
) |
This allows you to change the startNumber of a race.
By default, the race is started by driving through checkpoint 0, and, in a race with multiple laps, after passing the last checkpoint, the player will have to drive to checkpoint 0 again. You can change this here (useful to make small loops in a bigger race).
raceID | the ID of the race |
startNum | The number of the checkpoint that should be used as start point. Normally, the start line is position 0, the first checkpoint is position 1, etc. |
void Script2Script::racesManager::setupArrow | ( | int | position | ) |
Make the directional arrow point to a certain checkpoint of the current race.
position | The number of the checkpoint to which it should point. The start line is position 0, the first checkpoint is position 1, etc. It always points to a checkpoint of the current race |
void Script2Script::racesManager::setVersion | ( | int | raceID, |
string | version | ||
) |
This sets the version of your race.
raceID | the ID of the race |
version | The version of the race in the format 'username-v1.0' in which you replace 'username' by your username and '1.0' by the correct version number. |
void Script2Script::racesManager::startRace | ( | int | raceID | ) |
Starts a race.
raceID | the ID of the race |
void Script2Script::racesManager::unhideRace | ( | int | raceID | ) |
This shows your race again, after it was hidden.
raceID | the ID of the race |
void Script2Script::racesManager::unlockRace | ( | int | raceID | ) |
Unlocks a race.
raceID | the ID of the race |
bool Script2Script::racesManager::abortOnVehicleExit |
if true: if the user exits his vehicle, the race will be aborted. (default=false)
Definition at line 72 of file races.as.h.
int Script2Script::racesManager::ACTION_DoNothing |
Not used.
Definition at line 92 of file races.as.h.
int Script2Script::racesManager::ACTION_RestartRace |
Not used.
Definition at line 95 of file races.as.h.
int Script2Script::racesManager::ACTION_StopRace |
Not used.
Definition at line 94 of file races.as.h.
int Script2Script::racesManager::ACTION_SuspendRace |
Not used.
Definition at line 93 of file races.as.h.
int Script2Script::racesManager::actionOnTruckExit |
Definition at line 76 of file races.as.h.
bool Script2Script::racesManager::allowVehicleChanging |
if false: if the user changes vehicle, the race will be aborted. (default=false)
Definition at line 71 of file races.as.h.
int Script2Script::racesManager::ARROW_AUTO |
This arrow method will always point to the checkpoint instance that comes closest to the previous one.
Definition at line 101 of file races.as.h.
int Script2Script::racesManager::arrowMethod |
What checkpoint instance should the directional arrow point to. (default=ARROW_AUTO=point to the same instance as last checkpoint)
Definition at line 73 of file races.as.h.
|
private |
Definition at line 105 of file races.as.h.
int Script2Script::racesManager::cancelPointCount |
Definition at line 78 of file races.as.h.
int Script2Script::racesManager::currentLap |
the number of the current lap. (starts from 0)
Definition at line 60 of file races.as.h.
int Script2Script::racesManager::currentRace |
the ID of the current race. (-1 is there's no race running at the moment)
Definition at line 59 of file races.as.h.
int Script2Script::racesManager::LAPS_NoLaps |
This race has a seperate start line and finish line.
Definition at line 89 of file races.as.h.
int Script2Script::racesManager::LAPS_One |
This race consist of 1 lap, and the start and finish line are the same object.
Definition at line 90 of file races.as.h.
int Script2Script::racesManager::LAPS_Unlimited |
Keep looping the race for an unlimited time.
Definition at line 88 of file races.as.h.
double Script2Script::racesManager::lapStartTime |
Definition at line 80 of file races.as.h.
int Script2Script::racesManager::lastCheckpoint |
The number of the last passed checkpoint.
Definition at line 62 of file races.as.h.
string Script2Script::racesManager::lastCheckpointInstance |
Definition at line 81 of file races.as.h.
string Script2Script::racesManager::lastRaceEventInstance |
Definition at line 82 of file races.as.h.
double Script2Script::racesManager::lastRaceEventTime |
Definition at line 83 of file races.as.h.
bool Script2Script::racesManager::obligatedFinish |
if true: if you drive through the start checkpoint of another race, while racing, it will be ignored. (default=false)
Definition at line 64 of file races.as.h.
bool Script2Script::racesManager::penaltyGiven |
Definition at line 75 of file races.as.h.
int Script2Script::racesManager::raceCount |
the raceID+1 of the last race.
Definition at line 58 of file races.as.h.
|
private |
Definition at line 104 of file races.as.h.
string Script2Script::racesManager::raceManagerVersion |
the version of the raceManager
Definition at line 84 of file races.as.h.
double Script2Script::racesManager::raceStartTime |
Definition at line 79 of file races.as.h.
bool Script2Script::racesManager::showBestLap |
if true: If a race is started or a new best lap is set, the best lap will be shown. (default=true)
Definition at line 66 of file races.as.h.
bool Script2Script::racesManager::showBestRace |
if true: If a race is started or a new best race is set, the best race will be shown. (default=true)
Definition at line 67 of file races.as.h.
bool Script2Script::racesManager::showCheckPointInfoWhenNotInRace |
if true: if the user drives through a checkpoint of a race that isn't running, a message will be shown, saying "this is checkpoint xx of race myRaceName". (default=false)
Definition at line 69 of file races.as.h.
bool Script2Script::racesManager::showTimeDiff |
if true: Show + or - [best time minus current time] when passing a checkpoint. (default=true)
Definition at line 65 of file races.as.h.
bool Script2Script::racesManager::silentMode |
if true: No flashmessages will be shown. (default=false)
Definition at line 70 of file races.as.h.
int Script2Script::racesManager::state |
In which state are we?
Definition at line 77 of file races.as.h.
int Script2Script::racesManager::STATE_NotInRace |
We're not racing at the moment.
Definition at line 97 of file races.as.h.
int Script2Script::racesManager::STATE_Racing |
We're in the middle of a race :D.
Definition at line 99 of file races.as.h.
int Script2Script::racesManager::STATE_Waiting |
A race is suspended, and we're waiting until the race continues.
Definition at line 98 of file races.as.h.
bool Script2Script::racesManager::submitScore |
if true: If the user has a new best lap or new best race, this is submitted to the master server. (default=true)
Definition at line 68 of file races.as.h.
int Script2Script::racesManager::truckNum |
The number of the (last) used truck in the race.
Definition at line 61 of file races.as.h.