RigsofRods
Soft-body Physics Simulation
Script2Game::GameScriptClass Class Reference

Binding of RoR::GameScript; A general class that will provide you with general functions. More...

#include <GameScriptClass.h>

Public Member Functions

General
void log (string message)
 writes a message to the scripting logbook (AngelScript.log) More...
 
double getTime ()
 returns the time in seconds since the game was started More...
 
float rangeRandom (float from, float to)
 Generates a random number between from and to. More...
 
int useOnlineAPI (const string apiquery, const dictionary dict, string result)
 Sends or request information from the master server. More...
 
void getFPS ()
 Gets the Curent frames per second (FPS) More...
 
void getAvgFPS ()
 Gets the average frames per second (FPS) More...
 
void backToMenu ()
 Back to menu. More...
 
void quitGame ()
 Quits the game. More...
 
bool pushMessage (MsgType type, dictionary@ dict)
 Pushes a message to internal message queue. More...
 
bool checkResourceExists (const string &in filename, const string &in resource_group)
 Checks if the resource file exists in the given group. More...
 
bool deleteResource (const string &in filename, const string &in resource_group)
 Deletes a resource from the given group. More...
 
std::string loadTextResourceAsString (const string &in filename, const string &in resource_group)
 Loads a text file resource as string. More...
 
bool createTextResourceFromString (const string &in, const string &in filename, const string &in resource_group, bool overwrite=false)
 Saves a string as a text file resource. More...
 
AngelOgre::SceneManager getSceneManager ()
 Retrieves the OGRE scene manager object. More...
 
void openUrlInDefaultBrowser (const std::string &url)
 Opens URL (must start with 'http://' or 'https://') in system's default web browser. More...
 
void fetchUrlAsStringAsync (const std::string &url, const std::string &display_filename)
 Invokes a background thread to fetch data using CURL; when finished, sends MSG_APP_SCRIPT_THREAD_STATUS + Payload = RoR::ScriptEventArgs* (owner) - see SE_ANGELSCRIPT_THREAD_STATUS for arguments. More...
 
GUI
void flashMessage (string message, float time, float charHeight)
 shows a message to the user More...
 
void message (string txt, string icon, float timeMilliseconds, bool forceVisible)
 shows a message to the user More...
 
int getChatFontSize ()
 OBSOLETE - returns 0. More...
 
void setChatFontSize (int size)
 OBSOLETE - does nothing. More...
 
void showMessageBox (string mTitle, stringmText, bool button1, stringmButton1, bool AllowClose, bool button2, stringmButton2)
 Shows a message box. More...
 
void showChooser (string type, string instance, string box)
 This shows a vehicle chooser. More...
 
void updateDirectionArrow (string text, vector3 position)
 set direction arrow More...
 
void hideDirectionArrow ()
 Hides the direction arrow. More...
 
bool getScreenPosFromWorldPos (const vector3 &in, vector2 &out)
 
vector2 getDisplaySize ()
 Gets screen size in pixels. More...
 
Script management
void registerForEvent (int eventValue)
 registers for a new event to be received by the scripting system More...
 
void unRegisterEvent (int eventValue)
 unregisters from receiving event. More...
 
BitMask_t getRegisteredEventsMask (ScriptUnitId_t nid)
 Gets event mask for a specific running script. More...
 
void setRegisteredEventsMask (ScriptUnitId_t nid, BitMask_t eventMask)
 Overwrites event mask for a specific running script. More...
 
int addScriptFunction (const string func)
 Adds a global function to the script. More...
 
int scriptFunctionExists (const string func)
 Checks if a global function exists. More...
 
int deleteScriptFunction (const string func)
 Removes a global function from the script. More...
 
int addScriptVariable (const string var)
 Adds a global variable to the script. More...
 
int deleteScriptVariable (const string var)
 Removes a global variable from the script. More...
 
void clearEventCache ()
 Clears the event cache. More...
 
int sendGameCmd (const string &message)
 Multiplayer only: sends AngelScript snippet to all players. More...
 
array< int > getRunningScripts ()
 Returns active ScriptUnitIDs; check agains global var thisScript or use getScriptDetails() to get name etc... More...
 
dictionary getScriptDetails (int nid)
 Returns all info about running script; obtain the NID from getRunningScripts(), global var thisScript or event callbacks: More...
 
Terrain
void loadTerrain (string terrain)
 Loads a terrain. More...
 
int getLoadedTerrain (string result)
 Gets the currently loaded terrain name. More...
 
TerrainClass getTerrain ()
 Gets the currently loaded terrain instance. More...
 
bool getCaelumAvailable ()
 Checks if Caleum is enabled. More...
 
string getCaelumTime ()
 gets the time of the day in seconds More...
 
void setCaelumTime (float value)
 sets the time of the day in seconds More...
 
float getGravity ()
 returns the currently set upo gravity More...
 
void setGravity (float value)
 sets the gravity terrain wide. More...
 
float getWaterHeight ()
 returns the current base water level (without waves) More...
 
float getGroundHeight (vector3 position)
 returns the ground height for a position More...
 
void setWaterHeight (float value)
 sets the base water height More...
 
void spawnObject (const string objectName, const string instanceName, vector3 pos, vector3 rot, const string eventhandler, bool uniquifyMaterials)
 This spawns an object. More...
 
void moveObjectVisuals (const string instanceName, const vector3 pos)
 This moves an object to a new position. More...
 
void destroyObject (const string instanceName)
 This destroys an object. More...
 
bool getMousePositionOnTerrain (vector3 &out)
 Calculates mouse cursor position on terrain. More...
 
Character
vector3 getPersonPosition ()
 Returns the current position of the person. More...
 
void setPersonPosition (vector3 vec)
 sets the character position More...
 
void movePerson (vector3 relative_movement)
 moves the person relative More...
 
void setPersonRotation (radian &in)
 
radian getPersonRotation ()
 
Actors
void activateAllVehicles ()
 
void setTrucksForcedAwake (bool forceActive)
 
void boostCurrentTruck (float factor)
 Gives the currently used truck a boost in RPM. More...
 
BeamClass getCurrentTruck ()
 returns the current selected truck, null if in person mode More...
 
BeamClass getTruckByNum (int truck_number)
 Get an actor by Instance ID, get one from eventCallbackEx() or manually by BeamClass::getInstanceId(). More...
 
array< BeamClass@> getAllTrucks ()
 returns an array of all currently existing actors. More...
 
int getCurrentTruckNumber ()
 returns the instance ID of current player vehicle, or -1 when in person mode More...
 
BeamClass spawnTruck (stringtruckName, vector3 pos, vector3 rot)
 Spawns a truck by filename. More...
 
void repairVehicle (string instance, string box, bool keepPosition)
 This method repairs the vehicle in the box. More...
 
void removeVehicle (string instance, string box)
 This method removes the vehicle in the box. More...
 
int getNumTrucksByFlag (int flag)
 Number of trucks with flag. More...
 
Waypoint AI for Actors

to understand these values, run the game and look in TopMenubar UI->VehicleAI tab.

BeamClass spawnTruckAI (string truckName, vector3 pos, string truckSectionConfig, string truckSkin, int x)
 
array< vector3 > getWaypoints (int x)
 
void addWaypoint (vector3 pos)
 
int getAIVehicleCount ()
 
int getAIVehicleDistance ()
 
int getAIVehiclePositionScheme ()
 
int getAIVehicleSpeed ()
 
Ogre::String getAIVehicleName (int x)
 
Ogre::String getAIVehicleSectionConfig (int x)
 
std::string getAIVehicleSkin (int x)
 
int getAIRepeatTimes ()
 
int getAIMode ()
 
VehicleAIClass getCurrentTruckAI ()
 
VehicleAIClass getTruckAIByNum (int num)
 
void setAIVehicleCount (int count)
 
void setAIVehicleDistance (int dist)
 
void setAIVehiclePositionScheme (int scheme)
 
void setAIVehicleSpeed (int speed)
 
void setAIVehicleName (int x, string name)
 
void setAIVehicleSectionConfig (int x, string config)
 
void setAIVehicleSkin (int x, string skin)
 
void setAIRepeatTimes (int times)
 
void setAIMode (int mode)
 
Camera
void setCameraPosition (vector3 position)
 Sets the camera's position. More...
 
void setCameraDirection (vector3 direction)
 Sets the camera's direction vector. More...
 
void setCameraRoll (float angle)
 Rolls the camera anticlockwise, around its local z axis. More...
 
void setCameraYaw (float angle)
 Rotates the camera anticlockwise around it's local y axis. More...
 
void setCameraPitch (float angle)
 Pitches the camera up/down anticlockwise around it's local z axis. More...
 
vector3 getCameraPosition ()
 Retrieves the camera's position. More...
 
vector3 getCameraDirection ()
 Gets the camera's direction. More...
 
void cameraLookAt (vector3 targetPoint)
 Points the camera at a location in worldspace. More...
 
Race system
float stopTimer ()
 Stops the timer. More...
 
void startTimer ()
 Starts a timer (useful for races etc) More...
 
Material helpers
int setMaterialAmbient (const string materialName, float red, float green, float blue)
 
int setMaterialDiffuse (const string materialName, float red, float green, float blue, float alpha)
 
int setMaterialSpecular (const string materialName, float red, float green, float blue, float alpha)
 
int setMaterialEmissive (const string materialName, float red, float green, float blue)
 
int setMaterialTextureName (const string materialName, int techniqueNum, int passNum, int textureUnitNum, const string textureName)
 
int setMaterialTextureRotate (const string materialName, int techniqueNum, int passNum, int textureUnitNum, float rotation)
 
int setMaterialTextureScroll (const string materialName, int techniqueNum, int passNum, int textureUnitNum, float sx, float sy)
 
int setMaterialTextureScale (const string materialName, int techniqueNum, int passNum, int textureUnitNum, float u, float v)
 
Audio
array< SoundScriptTemplateClassgetAllSoundScriptTemplates ()
 
SoundScriptTemplateClass getSoundScriptTemplate (const string &in name)
 Retrieves one sound script template by name. More...
 
array< SoundScriptInstanceClassgetAllSoundScriptInstances ()
 Diagnostic function, returns all existing sound script instances. More...
 
SoundClass createSoundFromResource (const string &in filename, const string &in resource_group_name=string())
 
SoundScriptInstanceClass createSoundScriptInstance (const string &in template_name, int actor_instance_id=-1)
 

Detailed Description

Binding of RoR::GameScript; A general class that will provide you with general functions.

Note
Created automatically as global variable game. E.g.: you can log a message using game.log("Hi, I'm a message");

Definition at line 35 of file GameScriptClass.h.

Member Function Documentation

◆ activateAllVehicles()

void Script2Game::GameScriptClass::activateAllVehicles ( )

◆ addScriptFunction()

int Script2Game::GameScriptClass::addScriptFunction ( const string  func)

Adds a global function to the script.

Parameters
functhe function to be added, e.g.: "void func() { log('works'); }"

◆ addScriptVariable()

int Script2Game::GameScriptClass::addScriptVariable ( const string  var)

Adds a global variable to the script.

Parameters
varthe declaration of the variable that should be added, e.g.: "int missionState;"

◆ addWaypoint()

void Script2Game::GameScriptClass::addWaypoint ( vector3  pos)

◆ backToMenu()

void Script2Game::GameScriptClass::backToMenu ( )

Back to menu.

◆ boostCurrentTruck()

void Script2Game::GameScriptClass::boostCurrentTruck ( float  factor)

Gives the currently used truck a boost in RPM.

Parameters
factorThis factor determines by how much that the RPM of the truck will be increased ( rpm += 2000.0f * factor ).

◆ cameraLookAt()

void Script2Game::GameScriptClass::cameraLookAt ( vector3  targetPoint)

Points the camera at a location in worldspace.

Remarks
This is a helper method to automatically generate the direction vector for the camera, based on it's current position and the supplied look-at point.
Parameters
targetPointA vector specifying the look at point.

◆ checkResourceExists()

bool Script2Game::GameScriptClass::checkResourceExists ( const string &in  filename,
const string &in  resource_group 
)

Checks if the resource file exists in the given group.

KNOWN LIMITATION: If existing file is deleted externally, this function will still report it exists until the resource group is reloaded.

See also
https://ogrecave.github.io/ogre/api/latest/_resource-_management.html

◆ clearEventCache()

void Script2Game::GameScriptClass::clearEventCache ( )

Clears the event cache.

◆ createSoundFromResource()

SoundClass Script2Game::GameScriptClass::createSoundFromResource ( const string &in  filename,
const string &in  resource_group_name = string() 
)
Parameters
filenameWAV file; This WAV file MUST be mono, and exported as 16-bit PCM with no metadata.
resource_group_nameLeave empty to auto-search all groups (classic behavior).

◆ createSoundScriptInstance()

SoundScriptInstanceClass Script2Game::GameScriptClass::createSoundScriptInstance ( const string &in  template_name,
int  actor_instance_id = -1 
)
Parameters
template_nameName defined in the '.soundscript' file.
actor_instance_idValues 0 and larger are reserved as actor instance IDs, see getTruckByNum(); -1 means undefined, -2 is reserved for terrain objects.
See also
https://docs.rigsofrods.org/vehicle-creation/fileformat-soundscript

◆ createTextResourceFromString()

bool Script2Game::GameScriptClass::createTextResourceFromString ( const string &  in,
const string &in  filename,
const string &in  resource_group,
bool  overwrite = false 
)

Saves a string as a text file resource.

See also
https://ogrecave.github.io/ogre/api/latest/_resource-_management.html
Parameters
dataThe file data.
filenameResource name within the resource group, equivalent to filename without path.
resource_groupName of resource group to save to. If the group has multiple locations, first writable location is used.
overwriteBy default existing resources are not overwriten.
Returns
True on successful write. False if file not writable or exists and overwrite is disabled.

◆ deleteResource()

bool Script2Game::GameScriptClass::deleteResource ( const string &in  filename,
const string &in  resource_group 
)

Deletes a resource from the given group.

See also
https://ogrecave.github.io/ogre/api/latest/_resource-_management.html

◆ deleteScriptFunction()

int Script2Game::GameScriptClass::deleteScriptFunction ( const string  func)

Removes a global function from the script.

Parameters
functhe declaration of the function that should be removed, e.g.: "void func()"

◆ deleteScriptVariable()

int Script2Game::GameScriptClass::deleteScriptVariable ( const string  var)

Removes a global variable from the script.

Parameters
varthe declaration of the variable that should be removed, e.g.: "int missionState;"

◆ destroyObject()

void Script2Game::GameScriptClass::destroyObject ( const string  instanceName)

This destroys an object.

Parameters
instanceNameThe unique name that you chose when spawning this object
See also
spawnObject

◆ fetchUrlAsStringAsync()

void Script2Game::GameScriptClass::fetchUrlAsStringAsync ( const std::string &  url,
const std::string &  display_filename 
)

Invokes a background thread to fetch data using CURL; when finished, sends MSG_APP_SCRIPT_THREAD_STATUS + Payload = RoR::ScriptEventArgs* (owner) - see SE_ANGELSCRIPT_THREAD_STATUS for arguments.

◆ flashMessage()

void Script2Game::GameScriptClass::flashMessage ( string  message,
float  time,
float  charHeight 
)

shows a message to the user

Deprecated:
Use the game.message function instead.
Parameters
messageThe message to be shown
timeHow long the message should be shown (in seconds)
charHeightThe font size to be used (use -1 for the default size)

◆ getAIMode()

int Script2Game::GameScriptClass::getAIMode ( )

◆ getAIRepeatTimes()

int Script2Game::GameScriptClass::getAIRepeatTimes ( )

◆ getAIVehicleCount()

int Script2Game::GameScriptClass::getAIVehicleCount ( )

◆ getAIVehicleDistance()

int Script2Game::GameScriptClass::getAIVehicleDistance ( )

◆ getAIVehicleName()

Ogre::String Script2Game::GameScriptClass::getAIVehicleName ( int  x)

◆ getAIVehiclePositionScheme()

int Script2Game::GameScriptClass::getAIVehiclePositionScheme ( )

◆ getAIVehicleSectionConfig()

Ogre::String Script2Game::GameScriptClass::getAIVehicleSectionConfig ( int  x)

◆ getAIVehicleSkin()

std::string Script2Game::GameScriptClass::getAIVehicleSkin ( int  x)

◆ getAIVehicleSpeed()

int Script2Game::GameScriptClass::getAIVehicleSpeed ( )

◆ getAllSoundScriptInstances()

array<SoundScriptInstanceClass> Script2Game::GameScriptClass::getAllSoundScriptInstances ( )

Diagnostic function, returns all existing sound script instances.

◆ getAllSoundScriptTemplates()

array<SoundScriptTemplateClass> Script2Game::GameScriptClass::getAllSoundScriptTemplates ( )

◆ getAllTrucks()

array<BeamClass@> Script2Game::GameScriptClass::getAllTrucks ( )

returns an array of all currently existing actors.

◆ getAvgFPS()

void Script2Game::GameScriptClass::getAvgFPS ( )

Gets the average frames per second (FPS)

Returns
The average FPS

◆ getCaelumAvailable()

bool Script2Game::GameScriptClass::getCaelumAvailable ( )

Checks if Caleum is enabled.

Returns
true if Caleum is available

◆ getCaelumTime()

string Script2Game::GameScriptClass::getCaelumTime ( )

gets the time of the day in seconds

Returns
string with HH::MM::SS format

◆ getCameraDirection()

vector3 Script2Game::GameScriptClass::getCameraDirection ( )

Gets the camera's direction.

Returns
A vector representing the direction of the camera

◆ getCameraPosition()

vector3 Script2Game::GameScriptClass::getCameraPosition ( )

Retrieves the camera's position.

Returns
The current position of the camera

◆ getChatFontSize()

int Script2Game::GameScriptClass::getChatFontSize ( )

OBSOLETE - returns 0.

Deprecated:
Returns
always 0

◆ getCurrentTruck()

BeamClass Script2Game::GameScriptClass::getCurrentTruck ( )

returns the current selected truck, null if in person mode

Remarks
returns null if the truck does not exist
Returns
reference to Beam object that is currently in use

◆ getCurrentTruckAI()

VehicleAIClass Script2Game::GameScriptClass::getCurrentTruckAI ( )

◆ getCurrentTruckNumber()

int Script2Game::GameScriptClass::getCurrentTruckNumber ( )

returns the instance ID of current player vehicle, or -1 when in person mode

◆ getDisplaySize()

vector2 Script2Game::GameScriptClass::getDisplaySize ( )

Gets screen size in pixels.

◆ getFPS()

void Script2Game::GameScriptClass::getFPS ( )

Gets the Curent frames per second (FPS)

Returns
The Current FPS

◆ getGravity()

float Script2Game::GameScriptClass::getGravity ( )

returns the currently set upo gravity

Returns
float number describing gravity terrain wide.

◆ getGroundHeight()

float Script2Game::GameScriptClass::getGroundHeight ( vector3  position)

returns the ground height for a position

Parameters
positionThe position for which the height should be returned
Returns
ground height in meters

◆ getLoadedTerrain()

int Script2Game::GameScriptClass::getLoadedTerrain ( string  result)

Gets the currently loaded terrain name.

Parameters
resultThis string will contain the name of the terrain after you called this function
Returns
1 on success, 0 if terrain not loaded

◆ getMousePositionOnTerrain()

bool Script2Game::GameScriptClass::getMousePositionOnTerrain ( vector3 &  out)

Calculates mouse cursor position on terrain.

Parameters
out_posCalculated position, in meters.
Returns
true if mouse points to the terrain and output coordinates are valid.

◆ getNumTrucksByFlag()

int Script2Game::GameScriptClass::getNumTrucksByFlag ( int  flag)

Number of trucks with flag.

◆ getPersonPosition()

vector3 Script2Game::GameScriptClass::getPersonPosition ( )

Returns the current position of the person.

Returns
A vector containing the X, Y and Z coordinate of the person or an empty vector if the user is in a truck

◆ getPersonRotation()

radian Script2Game::GameScriptClass::getPersonRotation ( )

◆ getRegisteredEventsMask()

BitMask_t Script2Game::GameScriptClass::getRegisteredEventsMask ( ScriptUnitId_t  nid)

Gets event mask for a specific running script.

Intended for diagnostic and monitoring purposes.

Parameters
nidScriptUnitID, obtain one from global var thisScript or callback parameters.

◆ getRunningScripts()

array<int> Script2Game::GameScriptClass::getRunningScripts ( )

Returns active ScriptUnitIDs; check agains global var thisScript or use getScriptDetails() to get name etc...

◆ getSceneManager()

AngelOgre::SceneManager Script2Game::GameScriptClass::getSceneManager ( )

Retrieves the OGRE scene manager object.

◆ getScreenPosFromWorldPos()

bool Script2Game::GameScriptClass::getScreenPosFromWorldPos ( const vector3 &  in,
vector2 &  out 
)
Parameters
world_posThe world position to be converted, in meters.
out_screen_posThe resulting screen position, in pixels.
Returns
true if the world position is in front of the camera and the resulting screen position is valid.

◆ getScriptDetails()

dictionary Script2Game::GameScriptClass::getScriptDetails ( int  nid)

Returns all info about running script; obtain the NID from getRunningScripts(), global var thisScript or event callbacks:

  • "uniqueId" (int64)
  • "scriptName" (string)
  • "scriptCategory" (enum ScriptCategory)
  • "eventMask" (int64)
  • "scriptBuffer" (string)

◆ getSoundScriptTemplate()

SoundScriptTemplateClass Script2Game::GameScriptClass::getSoundScriptTemplate ( const string &in  name)

Retrieves one sound script template by name.

◆ getTerrain()

TerrainClass Script2Game::GameScriptClass::getTerrain ( )

Gets the currently loaded terrain instance.

◆ getTime()

double Script2Game::GameScriptClass::getTime ( )

returns the time in seconds since the game was started

Returns
time in seconds

◆ getTruckAIByNum()

VehicleAIClass Script2Game::GameScriptClass::getTruckAIByNum ( int  num)

◆ getTruckByNum()

BeamClass Script2Game::GameScriptClass::getTruckByNum ( int  truck_number)

Get an actor by Instance ID, get one from eventCallbackEx() or manually by BeamClass::getInstanceId().

Parameters
truck_numberActor instance ID.
See also
GameScriptClass.getCurrentTruckNumber()
Returns
returns null if the actor does not exist

◆ getWaterHeight()

float Script2Game::GameScriptClass::getWaterHeight ( )

returns the current base water level (without waves)

Returns
water height in meters

◆ getWaypoints()

array<vector3> Script2Game::GameScriptClass::getWaypoints ( int  x)

◆ hideDirectionArrow()

void Script2Game::GameScriptClass::hideDirectionArrow ( )

Hides the direction arrow.

See also
UpdateDirectionArrow

◆ loadTerrain()

void Script2Game::GameScriptClass::loadTerrain ( string  terrain)

Loads a terrain.

Warning
This doesn't unload the previous terrain! Always make sure that there's no terrain loaded before you use this method.
Parameters
terrainThe name of the terrain

◆ loadTextResourceAsString()

std::string Script2Game::GameScriptClass::loadTextResourceAsString ( const string &in  filename,
const string &in  resource_group 
)

Loads a text file resource as string.

See also
https://ogrecave.github.io/ogre/api/latest/_resource-_management.html
Parameters
filenameResource name within the resource group, equivalent to filename without path.
resource_groupName of resource group to load from

◆ log()

void Script2Game::GameScriptClass::log ( string  message)

writes a message to the scripting logbook (AngelScript.log)

Parameters
messagestring to log

◆ message()

void Script2Game::GameScriptClass::message ( string  txt,
string  icon,
float  timeMilliseconds,
bool  forceVisible 
)

shows a message to the user

Parameters
txtThe message to be shown
iconThe filename of the icon to be shown in front of the message.
timeMillisecondsHow long the message should be shown (in milliseconds)
forceVisibleSet this to true if you want the message to be forced on the user's screen (~it will show, even when the GUI is hidden).

◆ moveObjectVisuals()

void Script2Game::GameScriptClass::moveObjectVisuals ( const string  instanceName,
const vector3  pos 
)

This moves an object to a new position.

Note
This doesn't update the collision box!
Parameters
instanceNameThe unique name that you chose when spawning this object
posThe position where the object should be moved to

◆ movePerson()

void Script2Game::GameScriptClass::movePerson ( vector3  relative_movement)

moves the person relative

Parameters
relative_movementX, Y and Z coordinate of the translation

◆ openUrlInDefaultBrowser()

void Script2Game::GameScriptClass::openUrlInDefaultBrowser ( const std::string &  url)

Opens URL (must start with 'http://' or 'https://') in system's default web browser.

◆ pushMessage()

bool Script2Game::GameScriptClass::pushMessage ( MsgType  type,
dictionary@  dict 
)

Pushes a message to internal message queue.

Parameters are listed in Script2Game::MsgType comments.

Returns
True if the message was pushed, false if it was rejected.

◆ quitGame()

void Script2Game::GameScriptClass::quitGame ( )

Quits the game.

◆ rangeRandom()

float Script2Game::GameScriptClass::rangeRandom ( float  from,
float  to 
)

Generates a random number between from and to.

Parameters
fromThe generated number will be higher than this number
toThe generated number will be lower than this number
Returns
The random number between from and to

◆ registerForEvent()

void Script2Game::GameScriptClass::registerForEvent ( int  eventValue)

registers for a new event to be received by the scripting system

Parameters
eventValue
See also
enum scriptEvents

◆ removeVehicle()

void Script2Game::GameScriptClass::removeVehicle ( string  instance,
string  box 
)

This method removes the vehicle in the box.

◆ repairVehicle()

void Script2Game::GameScriptClass::repairVehicle ( string  instance,
string  box,
bool  keepPosition 
)

This method repairs the vehicle in the box.

◆ scriptFunctionExists()

int Script2Game::GameScriptClass::scriptFunctionExists ( const string  func)

Checks if a global function exists.

Parameters
functhe declaration of the function that should be checked for existance, e.g.: "void func()"

◆ sendGameCmd()

int Script2Game::GameScriptClass::sendGameCmd ( const string &  message)

Multiplayer only: sends AngelScript snippet to all players.

◆ setAIMode()

void Script2Game::GameScriptClass::setAIMode ( int  mode)

◆ setAIRepeatTimes()

void Script2Game::GameScriptClass::setAIRepeatTimes ( int  times)

◆ setAIVehicleCount()

void Script2Game::GameScriptClass::setAIVehicleCount ( int  count)

◆ setAIVehicleDistance()

void Script2Game::GameScriptClass::setAIVehicleDistance ( int  dist)

◆ setAIVehicleName()

void Script2Game::GameScriptClass::setAIVehicleName ( int  x,
string  name 
)

◆ setAIVehiclePositionScheme()

void Script2Game::GameScriptClass::setAIVehiclePositionScheme ( int  scheme)

◆ setAIVehicleSectionConfig()

void Script2Game::GameScriptClass::setAIVehicleSectionConfig ( int  x,
string  config 
)

◆ setAIVehicleSkin()

void Script2Game::GameScriptClass::setAIVehicleSkin ( int  x,
string  skin 
)

◆ setAIVehicleSpeed()

void Script2Game::GameScriptClass::setAIVehicleSpeed ( int  speed)

◆ setCaelumTime()

void Script2Game::GameScriptClass::setCaelumTime ( float  value)

sets the time of the day in seconds

Parameters
valueday time in seconds

◆ setCameraDirection()

void Script2Game::GameScriptClass::setCameraDirection ( vector3  direction)

Sets the camera's direction vector.

Parameters
directionA vector representing the direction of the vector.

◆ setCameraPitch()

void Script2Game::GameScriptClass::setCameraPitch ( float  angle)

Pitches the camera up/down anticlockwise around it's local z axis.

Parameters
angleThe pitch-angle

◆ setCameraPosition()

void Script2Game::GameScriptClass::setCameraPosition ( vector3  position)

Sets the camera's position.

Parameters
positionThe new position of the camera.

◆ setCameraRoll()

void Script2Game::GameScriptClass::setCameraRoll ( float  angle)

Rolls the camera anticlockwise, around its local z axis.

Parameters
angleThe roll-angle

◆ setCameraYaw()

void Script2Game::GameScriptClass::setCameraYaw ( float  angle)

Rotates the camera anticlockwise around it's local y axis.

Parameters
angleThe yaw-angle

◆ setChatFontSize()

void Script2Game::GameScriptClass::setChatFontSize ( int  size)

OBSOLETE - does nothing.

Deprecated:
Parameters
sizefont size in pixels

◆ setGravity()

void Script2Game::GameScriptClass::setGravity ( float  value)

sets the gravity terrain wide.

This is an expensive call, since the masses of all trucks are recalculated.

Parameters
valuenew gravity terrain wide (default is -9.81)

◆ setMaterialAmbient()

int Script2Game::GameScriptClass::setMaterialAmbient ( const string  materialName,
float  red,
float  green,
float  blue 
)

◆ setMaterialDiffuse()

int Script2Game::GameScriptClass::setMaterialDiffuse ( const string  materialName,
float  red,
float  green,
float  blue,
float  alpha 
)

◆ setMaterialEmissive()

int Script2Game::GameScriptClass::setMaterialEmissive ( const string  materialName,
float  red,
float  green,
float  blue 
)

◆ setMaterialSpecular()

int Script2Game::GameScriptClass::setMaterialSpecular ( const string  materialName,
float  red,
float  green,
float  blue,
float  alpha 
)

◆ setMaterialTextureName()

int Script2Game::GameScriptClass::setMaterialTextureName ( const string  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum,
const string  textureName 
)

◆ setMaterialTextureRotate()

int Script2Game::GameScriptClass::setMaterialTextureRotate ( const string  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum,
float  rotation 
)

◆ setMaterialTextureScale()

int Script2Game::GameScriptClass::setMaterialTextureScale ( const string  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum,
float  u,
float  v 
)

◆ setMaterialTextureScroll()

int Script2Game::GameScriptClass::setMaterialTextureScroll ( const string  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum,
float  sx,
float  sy 
)

◆ setPersonPosition()

void Script2Game::GameScriptClass::setPersonPosition ( vector3  vec)

sets the character position

Parameters
vecX, Y and Z coordinate of the position on the terrain

◆ setPersonRotation()

void Script2Game::GameScriptClass::setPersonRotation ( radian &  in)

◆ setRegisteredEventsMask()

void Script2Game::GameScriptClass::setRegisteredEventsMask ( ScriptUnitId_t  nid,
BitMask_t  eventMask 
)

Overwrites event mask for a specific running script.

Intended for debugging tools - use with caution.

Parameters
nidScriptUnitID, obtain one from global var thisScript or callback parameters.
eventMask
See also
enum scriptEvents

◆ setTrucksForcedAwake()

void Script2Game::GameScriptClass::setTrucksForcedAwake ( bool  forceActive)

◆ setWaterHeight()

void Script2Game::GameScriptClass::setWaterHeight ( float  value)

sets the base water height

Parameters
valuebase height in meters

◆ showChooser()

void Script2Game::GameScriptClass::showChooser ( string  type,
string  instance,
string  box 
)

This shows a vehicle chooser.

Parameters
typeA string specifying the type of the chooser. You can choose out of the following:
  • "vehicle"
  • "truck"
  • "car"
  • "boat"
  • "airplane"
  • "heli"
  • "trailer"
  • "load"
  • "extension"
instancethe unique name of the object with the event box in which the truck/load should be spawned
boxthe name of the box in which the truck will be spawned

◆ showMessageBox()

void Script2Game::GameScriptClass::showMessageBox ( string  mTitle,
stringmText  ,
bool  button1,
stringmButton1  ,
bool  AllowClose,
bool  button2,
stringmButton2   
)

Shows a message box.

Parameters
mTitleThe box title
mTextThe box content text
button1Set to true to show the first button
mButton1The text in the first button
AllowCloseIf set to true the user can close the box by pressing the X in the top-right
button2Set to true to show the second button
mButton2The text in the second button
See also
scriptEvents

◆ spawnObject()

void Script2Game::GameScriptClass::spawnObject ( const string  objectName,
const string  instanceName,
vector3  pos,
vector3  rot,
const string  eventhandler,
bool  uniquifyMaterials 
)

This spawns an object.

Parameters
objectNameThe name of the object (~the name of the odef file, but without the .odef extension)
instanceNameA unique name for this object (you can choose one, but make sure that you don't use the same name twice)
posThe position where the object should be spawned
rotThe rotation in which the object should be spawned
eventhandlerA name of a function that should be called when an event happens (events, as defined in the object definition file). Enter empty string to ignore events.
uniquifyMaterialsSet this to true if you need to uniquify the materials

◆ spawnTruck()

BeamClass Script2Game::GameScriptClass::spawnTruck ( stringtruckName  ,
vector3  pos,
vector3  rot 
)

Spawns a truck by filename.

Parameters
truckNameThe filename of the truck
posThe position where the truck should be spawned
rotThe rotation in which the truck should be spawned
Returns
reference to Beam object

◆ spawnTruckAI()

BeamClass Script2Game::GameScriptClass::spawnTruckAI ( string  truckName,
vector3  pos,
string  truckSectionConfig,
string  truckSkin,
int  x 
)

◆ startTimer()

void Script2Game::GameScriptClass::startTimer ( )

Starts a timer (useful for races etc)

See also
stopTimer

◆ stopTimer()

float Script2Game::GameScriptClass::stopTimer ( )

Stops the timer.

See also
startTimer
Returns
The time that passed since the timer started

◆ unRegisterEvent()

void Script2Game::GameScriptClass::unRegisterEvent ( int  eventValue)

unregisters from receiving event.

Parameters
eventValue
See also
enum scriptEvents

◆ updateDirectionArrow()

void Script2Game::GameScriptClass::updateDirectionArrow ( string  text,
vector3  position 
)

set direction arrow

Parameters
texttext to be displayed. "" to hide the text
positionThe position to which the arrow should point.
See also
hideDirectionArrow

◆ useOnlineAPI()

int Script2Game::GameScriptClass::useOnlineAPI ( const string  apiquery,
const dictionary  dict,
string  result 
)

Sends or request information from the master server.


The documentation for this class was generated from the following file: