RigsofRods
Soft-body Physics Simulation
Private Member Functions
RoR::GameScript Class Reference

Proxy class that can be called by script functions. More...

#include <GameScript.h>

Public Member Functions

General
void log (const Ogre::String &msg)
 writes a message to the games log (RoR.log) More...
 
float getTime ()
 returns the time in seconds since the game was started More...
 
void backToMenu ()
 
void quitGame ()
 
float getFPS ()
 
float getAvgFPS ()
 
float rangeRandom (float from, float to)
 
int useOnlineAPI (const Ogre::String &apiquery, const AngelScript::CScriptDictionary &dict, Ogre::String &result)
 
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...
 
bool pushMessage (MsgType type, AngelScript::CScriptDictionary *dict)
 Pushes a message to internal message queue. More...
 
bool checkResourceExists (const std::string &filename, const std::string &resource_group)
 Checks if the resource file exists in the given group. More...
 
bool deleteResource (const std::string &filename, const std::string &resource_group)
 Deletes a resource from the given group. More...
 
std::string loadTextResourceAsString (const std::string &filename, const std::string &resource_group)
 Loads a text file resource as string. More...
 
bool createTextResourceFromString (const std::string &data, const std::string &filename, const std::string &resource_group, bool overwrite=false)
 Saves a string as a text file resource. More...
 
Ogre::SceneManager * getSceneManager ()
 
AngelScript::CScriptArray * findResourceFileInfo (const std::string &resource_group, const std::string &pattern, bool dirs=false)
 Proxy to Ogre::ResourceGroupManager::findResourceFileInfo(), see https://ogrecave.github.io/ogre/api/1.11/class_ogre_1_1_resource_group_manager.html#a662f68163310401718d3c3981a7baec4. More...
 
Ogre::Image loadImageResource (const std::string &filename, const std::string &resource_group)
 Loads an image in any format recognized by OGRE. More...
 
bool serializeMeshResource (const std::string &filename, const std::string &resource_group, const Ogre::MeshPtr &mesh)
 Uses Ogre::MeshSerializer to save binary .mesh file (latest format, native endianness). More...
 
GUI
void flashMessage (Ogre::String &txt, float time, float charHeight)
 DEPRECATED: use message() shows a message to the user. More...
 
void message (Ogre::String &txt, Ogre::String &icon)
 shows a message to the user over the console system More...
 
int getChatFontSize ()
 OBSOLETE, returns 0;. More...
 
void setChatFontSize (int size)
 OBSOLETE, does nothing. More...
 
void showMessageBox (Ogre::String &title, Ogre::String &text, bool use_btn1, Ogre::String &btn1_text, bool allow_close, bool use_btn2, Ogre::String &btn2_text)
 
void showChooser (const Ogre::String &type, const Ogre::String &instance, const Ogre::String &box)
 
void updateDirectionArrow (Ogre::String &text, Ogre::Vector3 &vec)
 set direction arrow More...
 
void hideDirectionArrow ()
 
bool getScreenPosFromWorldPos (Ogre::Vector3 const &world_pos, Ogre::Vector2 &out_screen_pos)
 
Ogre::Vector2 getDisplaySize ()
 Gets screen size in pixels. More...
 
Ogre::Vector2 getMouseScreenPosition ()
 Gets mouse position 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 Ogre::String &arg)
 Adds a global function to the script (Wrapper for ScriptEngine::addFunction) More...
 
int scriptFunctionExists (const Ogre::String &arg)
 Checks if a global function exists in the script (Wrapper for ScriptEngine::functionExists) More...
 
int deleteScriptFunction (const Ogre::String &arg)
 Deletes a global function from the script (Wrapper for ScriptEngine::deleteFunction) More...
 
int addScriptVariable (const Ogre::String &arg)
 Adds a global variable to the script (Wrapper for ScriptEngine::addVariable) More...
 
int deleteScriptVariable (const Ogre::String &arg)
 Deletes a global variable from the script (Wrapper for ScriptEngine::deleteVariable) More...
 
void clearEventCache ()
 
int sendGameCmd (const Ogre::String &message)
 Multiplayer only: sends AngelScript snippet to all players. More...
 
AngelScript::CScriptArray * getRunningScripts ()
 Returns array<int> with active ScriptUnitIDs; check agains global var thisScript or use getScriptDetails() to get name etc... More...
 
AngelScript::CScriptDictionary * getScriptDetails (ScriptUnitId_t nid)
 Returns all info about running script; obtain the NID from getRunningScripts(), global var thisScript or event callbacks: More...
 
Terrain
void loadTerrain (const Ogre::String &terrain)
 
int getLoadedTerrain (Ogre::String &result)
 gets the name of current terrain. More...
 
bool getCaelumAvailable ()
 
Ogre::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 getGroundHeight (Ogre::Vector3 &v)
 Gets terrain height at given coordinates. More...
 
float getWaterHeight ()
 returns the current base water level (without waves) More...
 
void setWaterHeight (float value)
 sets the base water height More...
 
void spawnObject (const Ogre::String &objectName, const Ogre::String &instanceName, const Ogre::Vector3 &pos, const Ogre::Vector3 &rot, const Ogre::String &eventhandler, bool uniquifyMaterials)
 This spawns a static terrain object (.ODEF file) More...
 
void moveObjectVisuals (const Ogre::String &instanceName, const Ogre::Vector3 &pos)
 This moves an object to a new position. More...
 
void destroyObject (const Ogre::String &instanceName)
 This destroys an object. More...
 
bool getMousePositionOnTerrain (Ogre::Vector3 &out_pos)
 Calculates mouse cursor position on terrain. More...
 
TerrainPtr getTerrain ()
 
Character
Ogre::Vector3 getPersonPosition ()
 
void setPersonPosition (const Ogre::Vector3 &vec)
 sets the character position More...
 
void movePerson (const Ogre::Vector3 &vec)
 moves the person relative More...
 
void setPersonRotation (const Ogre::Radian &rot)
 sets the character rotation More...
 
Ogre::Radian getPersonRotation ()
 gets the character rotation More...
 
Actors
void activateAllVehicles ()
 
void setTrucksForcedAwake (bool forceActive)
 
void boostCurrentTruck (float factor)
 
ActorPtr getCurrentTruck ()
 returns the current selected truck, 0 if in person mode More...
 
ActorPtr getTruckByNum (int num)
 returns a truck by index, get max index by calling getNumTrucks More...
 
AngelScript::CScriptArray * getAllTrucks ()
 returns an array of all currently existing actors. More...
 
int getCurrentTruckNumber ()
 returns the current truck number. More...
 
ActorPtr spawnTruck (Ogre::String &truckName, Ogre::Vector3 &pos, Ogre::Vector3 &rot)
 
void repairVehicle (const Ogre::String &instance, const Ogre::String &box, bool keepPosition)
 
void removeVehicle (const Ogre::String &instance, const Ogre::String &box)
 
int getNumTrucksByFlag (int flag)
 
FreeForces - see <tt>game.pushMessage()</tt>
FreeForceID_t getFreeForceNextId ()
 Returns an unused (not reused) ID to use with MSG_SIM_ADD_FREEFORCE_REQUESTED; see game.pushMessage(). More...
 
Waypoint AI for Actors; to understand these values, look in TopMenubar UI->VehicleAI tab.
ActorPtr spawnTruckAI (Ogre::String &truckName, Ogre::Vector3 &pos, Ogre::String &truckSectionConfig, std::string &truckSkin, int x)
 
AngelScript::CScriptArray * getWaypoints (int x)
 
AngelScript::CScriptArray * getWaypointsSpeed ()
 
void addWaypoint (const Ogre::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 ()
 
VehicleAIPtr getCurrentTruckAI ()
 
VehicleAIPtr getTruckAIByNum (int num)
 
void setAIVehicleCount (int count)
 
void setAIVehicleDistance (int dist)
 
void setAIVehiclePositionScheme (int scheme)
 
void setAIVehicleSpeed (int speed)
 
void setAIVehicleName (int x, std::string name)
 
void setAIVehicleSectionConfig (int x, std::string config)
 
void setAIVehicleSkin (int x, std::string skin)
 
void setAIRepeatTimes (int times)
 
void setAIMode (int mode)
 
Camera
void setCameraPosition (const Ogre::Vector3 &pos)
 Sets the camera's position. More...
 
void setCameraDirection (const Ogre::Vector3 &vec)
 Sets the camera's direction vector. More...
 
void setCameraOrientation (const Ogre::Quaternion &q)
 Sets the camera's orientation. 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...
 
Ogre::Vector3 getCameraPosition ()
 Retrieves the camera's position. More...
 
Ogre::Vector3 getCameraDirection ()
 Gets the camera's direction. More...
 
Ogre::Quaternion getCameraOrientation ()
 Gets the camera's orientation. More...
 
void cameraLookAt (const Ogre::Vector3 &targetPoint)
 Points the camera at a location in worldspace. More...
 
Race system
void stopTimer ()
 
void startTimer (int id)
 
void setTimeDiff (float diff)
 
void setBestLapTime (float time)
 
Material helpers
int setMaterialAmbient (const Ogre::String &materialName, float red, float green, float blue)
 
int setMaterialDiffuse (const Ogre::String &materialName, float red, float green, float blue, float alpha)
 
int setMaterialSpecular (const Ogre::String &materialName, float red, float green, float blue, float alpha)
 
int setMaterialEmissive (const Ogre::String &materialName, float red, float green, float blue)
 
int setMaterialTextureName (const Ogre::String &materialName, int techniqueNum, int passNum, int textureUnitNum, const Ogre::String &textureName)
 
int setMaterialTextureRotate (const Ogre::String &materialName, int techniqueNum, int passNum, int textureUnitNum, float rotation)
 
int setMaterialTextureScroll (const Ogre::String &materialName, int techniqueNum, int passNum, int textureUnitNum, float sx, float sy)
 
int setMaterialTextureScale (const Ogre::String &materialName, int techniqueNum, int passNum, int textureUnitNum, float u, float v)
 
Audio
AngelScript::CScriptArray * getAllSoundScriptTemplates ()
 
SoundScriptTemplatePtr getSoundScriptTemplate (const std::string &name)
 
AngelScript::CScriptArray * getAllSoundScriptInstances ()
 
SoundPtr createSoundFromResource (const std::string &filename, const std::string &resource_group_name)
 
SoundScriptInstancePtr createSoundScriptInstance (const std::string &template_name, int actor_instance_id)
 

Private Member Functions

bool HaveSimTerrain (const char *func_name)
 Helper; Check if SimController instance exists, log warning if not. More...
 
bool HavePlayerAvatar (const char *func_name)
 Helper; Check if local Character instance exists, log warning if not. More...
 
bool HaveMainCamera (const char *func_name)
 Helper; Check if main camera exists, log warning if not. More...
 
std::string CheckFileAccess (const char *func_name, const std::string &filename, const std::string &resource_group)
 Extract filename and extension from the input, because OGRE allows absolute paths in resource system. More...
 
int getTextureUnitState (Ogre::TextureUnitState **tu, const Ogre::String materialName, int techniqueNum, int passNum, int textureUnitNum)
 
void logFormat (const char *fmt,...)
 writes a message to the games log (RoR.log) More...
 

Detailed Description

Proxy class that can be called by script functions.

Definition at line 41 of file GameScript.h.

Member Function Documentation

◆ activateAllVehicles()

void GameScript::activateAllVehicles ( )

Definition at line 99 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ addScriptFunction()

int GameScript::addScriptFunction ( const Ogre::String &  arg)

Adds a global function to the script (Wrapper for ScriptEngine::addFunction)

Parameters
argA declaration for the function.

Definition at line 949 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ addScriptVariable()

int GameScript::addScriptVariable ( const Ogre::String &  arg)

Adds a global variable to the script (Wrapper for ScriptEngine::addVariable)

Parameters
argA declaration for the variable.

Definition at line 964 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ addWaypoint()

void GameScript::addWaypoint ( const Ogre::Vector3 &  pos)

Definition at line 1132 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ backToMenu()

void GameScript::backToMenu ( )

Definition at line 1332 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ boostCurrentTruck()

void GameScript::boostCurrentTruck ( float  factor)

Definition at line 938 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ cameraLookAt()

void GameScript::cameraLookAt ( const Ogre::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.

Definition at line 798 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ CheckFileAccess()

std::string GameScript::CheckFileAccess ( const char *  func_name,
const std::string &  filename,
const std::string &  resource_group 
)
private

Extract filename and extension from the input, because OGRE allows absolute paths in resource system.

Definition at line 1963 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ checkResourceExists()

bool GameScript::checkResourceExists ( const std::string &  filename,
const std::string &  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

Definition at line 1748 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ clearEventCache()

void GameScript::clearEventCache ( )

Definition at line 709 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ createSoundFromResource()

SoundPtr GameScript::createSoundFromResource ( const std::string &  filename,
const std::string &  resource_group_name 
)
Parameters
filenameWAV file.
resource_group_nameLeave empty to auto-search all groups (classic behavior).

Definition at line 1738 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ createSoundScriptInstance()

SoundScriptInstancePtr GameScript::createSoundScriptInstance ( const std::string &  template_name,
int  actor_instance_id = SoundScriptInstance::ACTOR_ID_UNKNOWN 
)

Definition at line 1743 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ createTextResourceFromString()

bool GameScript::createTextResourceFromString ( const std::string &  data,
const std::string &  filename,
const std::string &  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.

Definition at line 1833 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ deleteResource()

bool GameScript::deleteResource ( const std::string &  filename,
const std::string &  resource_group 
)

Deletes a resource from the given group.

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

Definition at line 1766 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ deleteScriptFunction()

int GameScript::deleteScriptFunction ( const Ogre::String &  arg)

Deletes a global function from the script (Wrapper for ScriptEngine::deleteFunction)

Parameters
argA declaration for the function.

Definition at line 959 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ deleteScriptVariable()

int GameScript::deleteScriptVariable ( const Ogre::String &  arg)

Deletes a global variable from the script (Wrapper for ScriptEngine::deleteVariable)

Parameters
argA declaration for the variable.

Definition at line 969 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ destroyObject()

void GameScript::destroyObject ( const Ogre::String &  instanceName)

This destroys an object.

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

Definition at line 396 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ fetchUrlAsStringAsync()

void GameScript::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.

Definition at line 922 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ findResourceFileInfo()

AngelScript::CScriptArray * GameScript::findResourceFileInfo ( const std::string &  resource_group,
const std::string &  pattern,
bool  dirs = false 
)

Proxy to Ogre::ResourceGroupManager::findResourceFileInfo(), see https://ogrecave.github.io/ogre/api/1.11/class_ogre_1_1_resource_group_manager.html#a662f68163310401718d3c3981a7baec4.

Definition at line 1861 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ flashMessage()

void GameScript::flashMessage ( Ogre::String &  txt,
float  time,
float  charHeight 
)

DEPRECATED: use message() shows a message to the user.

Definition at line 323 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIMode()

int GameScript::getAIMode ( )

Definition at line 1232 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIRepeatTimes()

int GameScript::getAIRepeatTimes ( )

Definition at line 1226 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIVehicleCount()

int GameScript::getAIVehicleCount ( )

Definition at line 1160 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIVehicleDistance()

int GameScript::getAIVehicleDistance ( )

Definition at line 1166 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIVehicleName()

Ogre::String GameScript::getAIVehicleName ( int  x)

Definition at line 1184 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIVehiclePositionScheme()

int GameScript::getAIVehiclePositionScheme ( )

Definition at line 1172 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIVehicleSectionConfig()

Ogre::String GameScript::getAIVehicleSectionConfig ( int  x)

Definition at line 1198 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIVehicleSkin()

std::string GameScript::getAIVehicleSkin ( int  x)

Definition at line 1212 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAIVehicleSpeed()

int GameScript::getAIVehicleSpeed ( )

Definition at line 1178 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAllSoundScriptInstances()

AngelScript::CScriptArray * GameScript::getAllSoundScriptInstances ( )

Definition at line 1733 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAllSoundScriptTemplates()

CScriptArray * GameScript::getAllSoundScriptTemplates ( )

Definition at line 1723 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAllTrucks()

AngelScript::CScriptArray * GameScript::getAllTrucks ( )

returns an array of all currently existing actors.

Returns
array<BeamClass@>

Definition at line 1118 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getAvgFPS()

float GameScript::getAvgFPS ( )

Definition at line 1348 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getCaelumAvailable()

bool GameScript::getCaelumAvailable ( )

Definition at line 181 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getCaelumTime()

String GameScript::getCaelumTime ( )

gets the time of the day in seconds

Returns
string with HH::MM::SS format

Definition at line 159 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getCameraDirection()

Vector3 GameScript::getCameraDirection ( )

Gets the camera's direction.

Returns
A vector representing the direction of the camera

Definition at line 779 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getCameraOrientation()

Quaternion GameScript::getCameraOrientation ( )

Gets the camera's orientation.

Returns
A quaternion representing the orientation of the camera

Definition at line 790 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getCameraPosition()

Vector3 GameScript::getCameraPosition ( )

Retrieves the camera's position.

Returns
The current position of the camera

Definition at line 771 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getChatFontSize()

int GameScript::getChatFontSize ( )

OBSOLETE, returns 0;.

Definition at line 338 of file GameScript.cpp.

◆ getCurrentTruck()

ActorPtr GameScript::getCurrentTruck ( )

returns the current selected truck, 0 if in person mode

Returns
reference to Beam object that is currently in use

Definition at line 240 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getCurrentTruckAI()

VehicleAIPtr GameScript::getCurrentTruckAI ( )

Definition at line 1025 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getCurrentTruckNumber()

int GameScript::getCurrentTruckNumber ( )

returns the current truck number.

>=0 when using a truck, -1 when in person mode

Returns
integer truck number

Definition at line 279 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getDisplaySize()

Ogre::Vector2 GameScript::getDisplaySize ( )

Gets screen size in pixels.

Definition at line 495 of file GameScript.cpp.

◆ getFPS()

float GameScript::getFPS ( )

Definition at line 1343 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getFreeForceNextId()

FreeForceID_t GameScript::getFreeForceNextId ( )

Returns an unused (not reused) ID to use with MSG_SIM_ADD_FREEFORCE_REQUESTED; see game.pushMessage().

Definition at line 1715 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getGravity()

float GameScript::getGravity ( )

returns the currently set upo gravity

Returns
float number describing gravity terrain wide.

Definition at line 245 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getGroundHeight()

float GameScript::getGroundHeight ( Ogre::Vector3 &  v)

Gets terrain height at given coordinates.

Definition at line 224 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getLoadedTerrain()

int GameScript::getLoadedTerrain ( Ogre::String &  result)

gets the name of current terrain.

Returns
1 on success, 0 if terrain not loaded

Definition at line 691 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getMousePositionOnTerrain()

bool GameScript::getMousePositionOnTerrain ( Ogre::Vector3 &  out_pos)

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.

Definition at line 1353 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getMouseScreenPosition()

Ogre::Vector2 GameScript::getMouseScreenPosition ( )

Gets mouse position in pixels.

Definition at line 501 of file GameScript.cpp.

◆ getNumTrucksByFlag()

int GameScript::getNumTrucksByFlag ( int  flag)

Definition at line 268 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getPersonPosition()

Vector3 GameScript::getPersonPosition ( )

Definition at line 127 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getPersonRotation()

Radian GameScript::getPersonRotation ( )

gets the character rotation

Returns
character rotation

Definition at line 151 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getRegisteredEventsMask()

BitMask_t GameScript::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.

Definition at line 309 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getRunningScripts()

AngelScript::CScriptArray * GameScript::getRunningScripts ( )

Returns array<int> with active ScriptUnitIDs; check agains global var thisScript or use getScriptDetails() to get name etc...

Definition at line 987 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getSceneManager()

Ogre::SceneManager * GameScript::getSceneManager ( )

Definition at line 1368 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getScreenPosFromWorldPos()

bool GameScript::getScreenPosFromWorldPos ( Ogre::Vector3 const &  world_pos,
Ogre::Vector2 &  out_screen_pos 
)
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.

Definition at line 480 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getScriptDetails()

AngelScript::CScriptDictionary * GameScript::getScriptDetails ( ScriptUnitId_t  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)

Definition at line 997 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getSoundScriptTemplate()

SoundScriptTemplatePtr GameScript::getSoundScriptTemplate ( const std::string &  name)

Definition at line 1728 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getTerrain()

RoR::TerrainPtr GameScript::getTerrain ( )

Definition at line 704 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getTextureUnitState()

int GameScript::getTextureUnitState ( Ogre::TextureUnitState **  tu,
const Ogre::String  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum 
)
private

Definition at line 575 of file GameScript.cpp.

◆ getTime()

float GameScript::getTime ( )

returns the time in seconds since the game was started

Returns
time in seconds

Definition at line 109 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getTruckAIByNum()

VehicleAIPtr GameScript::getTruckAIByNum ( int  num)

Definition at line 1035 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getTruckByNum()

ActorPtr GameScript::getTruckByNum ( int  num)

returns a truck by index, get max index by calling getNumTrucks

Returns
reference to Beam object that the selected slot

Definition at line 263 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getWaterHeight()

float GameScript::getWaterHeight ( )

returns the current base water level (without waves)

Returns
water height in meters

Definition at line 232 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getWaypoints()

AngelScript::CScriptArray * GameScript::getWaypoints ( int  x)

Definition at line 1095 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ getWaypointsSpeed()

AngelScript::CScriptArray * GameScript::getWaypointsSpeed ( )

Definition at line 1141 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ HaveMainCamera()

bool GameScript::HaveMainCamera ( const char *  func_name)
private

Helper; Check if main camera exists, log warning if not.

Definition at line 1953 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ HavePlayerAvatar()

bool GameScript::HavePlayerAvatar ( const char *  func_name)
private

Helper; Check if local Character instance exists, log warning if not.

Definition at line 1943 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ HaveSimTerrain()

bool GameScript::HaveSimTerrain ( const char *  func_name)
private

Helper; Check if SimController instance exists, log warning if not.

Definition at line 1933 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ hideDirectionArrow()

void GameScript::hideDirectionArrow ( )

Definition at line 475 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ loadImageResource()

Ogre::Image GameScript::loadImageResource ( const std::string &  filename,
const std::string &  resource_group 
)

Loads an image in any format recognized by OGRE.

Definition at line 1892 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ loadTerrain()

void GameScript::loadTerrain ( const Ogre::String &  terrain)

Definition at line 122 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ loadTextResourceAsString()

std::string GameScript::loadTextResourceAsString ( const std::string &  filename,
const std::string &  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

Definition at line 1785 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ log()

void GameScript::log ( const Ogre::String &  msg)

writes a message to the games log (RoR.log)

Parameters
msgstring to log

Definition at line 80 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ logFormat()

void GameScript::logFormat ( const char *  fmt,
  ... 
)
private

writes a message to the games log (RoR.log)

Parameters
msgstring to log

Definition at line 85 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ message()

void GameScript::message ( Ogre::String &  txt,
Ogre::String &  icon 
)

shows a message to the user over the console system

Definition at line 328 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ moveObjectVisuals()

void GameScript::moveObjectVisuals ( const Ogre::String &  instanceName,
const Ogre::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

Definition at line 407 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ movePerson()

void GameScript::movePerson ( const Ogre::Vector3 &  vec)

moves the person relative

Parameters
vectranslation vector

Definition at line 135 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ openUrlInDefaultBrowser()

void GameScript::openUrlInDefaultBrowser ( const std::string &  url)

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

Definition at line 917 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ pushMessage()

bool GameScript::pushMessage ( MsgType  type,
AngelScript::CScriptDictionary *  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.

< Payload = RoR::LoadScriptRequest* (owner)

< Payload = RoR::ScriptUnitId_t* (owner)

< Payload = RoR::ActorSpawnRequest* (owner)

< Payload = RoR::ActorModifyRequest* (owner)

< Payload = RoR::ActorPtr* (owner)

< Payload = ActorPtr* (owner)

< Payload = ActorPtr* (owner)

< Payload = RoR::ActorPtr (owner) | nullptr

< Payload = Ogre::Vector3* (owner)

< Payload = RoR::CacheEntryPtr* (owner)

< Payload = RoR::CacheEntryPtr* (owner)

< Payload = RoR::CacheEntryPtr* (owner)

< Payload = RoR::CreateProjectRequest* (owner)

Definition at line 1373 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ quitGame()

void GameScript::quitGame ( )

Definition at line 1338 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ rangeRandom()

float GameScript::rangeRandom ( float  from,
float  to 
)

Definition at line 686 of file GameScript.cpp.

◆ registerForEvent()

void GameScript::registerForEvent ( int  eventValue)

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

Parameters
eventValue
See also
enum scriptEvents

Definition at line 285 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ removeVehicle()

void GameScript::removeVehicle ( const Ogre::String &  instance,
const Ogre::String &  box 
)

Definition at line 387 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ repairVehicle()

void GameScript::repairVehicle ( const Ogre::String &  instance,
const Ogre::String &  box,
bool  keepPosition 
)

Definition at line 382 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ scriptFunctionExists()

int GameScript::scriptFunctionExists ( const Ogre::String &  arg)

Checks if a global function exists in the script (Wrapper for ScriptEngine::functionExists)

Parameters
argA declaration for the function.

Definition at line 954 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ sendGameCmd()

int GameScript::sendGameCmd ( const Ogre::String &  message)

Multiplayer only: sends AngelScript snippet to all players.

Definition at line 974 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ serializeMeshResource()

bool GameScript::serializeMeshResource ( const std::string &  filename,
const std::string &  resource_group,
const Ogre::MeshPtr &  mesh 
)

Uses Ogre::MeshSerializer to save binary .mesh file (latest format, native endianness).

Definition at line 1910 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIMode()

void GameScript::setAIMode ( int  mode)

Definition at line 1309 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIRepeatTimes()

void GameScript::setAIRepeatTimes ( int  times)

Definition at line 1304 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIVehicleCount()

void GameScript::setAIVehicleCount ( int  count)

Definition at line 1240 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIVehicleDistance()

void GameScript::setAIVehicleDistance ( int  dist)

Definition at line 1245 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIVehicleName()

void GameScript::setAIVehicleName ( int  x,
std::string  name 
)

Definition at line 1260 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIVehiclePositionScheme()

void GameScript::setAIVehiclePositionScheme ( int  scheme)

Definition at line 1250 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIVehicleSectionConfig()

void GameScript::setAIVehicleSectionConfig ( int  x,
std::string  config 
)

Definition at line 1272 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIVehicleSkin()

void GameScript::setAIVehicleSkin ( int  x,
std::string  skin 
)

Definition at line 1288 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setAIVehicleSpeed()

void GameScript::setAIVehicleSpeed ( int  speed)

Definition at line 1255 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setBestLapTime()

void GameScript::setBestLapTime ( float  time)

Definition at line 206 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setCaelumTime()

void GameScript::setCaelumTime ( float  value)

sets the time of the day in seconds

Parameters
valueday time in seconds

Definition at line 171 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setCameraDirection()

void GameScript::setCameraDirection ( const Ogre::Vector3 &  vec)

Sets the camera's direction vector.

Parameters
vecA vector representing the direction of the vector.

Definition at line 731 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setCameraOrientation()

void GameScript::setCameraOrientation ( const Ogre::Quaternion &  q)

Sets the camera's orientation.

Parameters
vecA vector representing the direction of the vector.

Definition at line 739 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setCameraPitch()

void GameScript::setCameraPitch ( float  angle)

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

Parameters
angleThe pitch-angle

Definition at line 755 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setCameraPosition()

void GameScript::setCameraPosition ( const Ogre::Vector3 &  pos)

Sets the camera's position.

Parameters
posThe new position of the camera.

Definition at line 723 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setCameraRoll()

void GameScript::setCameraRoll ( float  angle)

Rolls the camera anticlockwise, around its local z axis.

Parameters
angleThe roll-angle

Definition at line 763 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setCameraYaw()

void GameScript::setCameraYaw ( float  angle)

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

Parameters
angleThe yaw-angle

Definition at line 747 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setChatFontSize()

void GameScript::setChatFontSize ( int  size)

OBSOLETE, does nothing.

Definition at line 343 of file GameScript.cpp.

◆ setGravity()

void GameScript::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)

Definition at line 255 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setMaterialAmbient()

int GameScript::setMaterialAmbient ( const Ogre::String &  materialName,
float  red,
float  green,
float  blue 
)

Definition at line 507 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setMaterialDiffuse()

int GameScript::setMaterialDiffuse ( const Ogre::String &  materialName,
float  red,
float  green,
float  blue,
float  alpha 
)

Definition at line 524 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setMaterialEmissive()

int GameScript::setMaterialEmissive ( const Ogre::String &  materialName,
float  red,
float  green,
float  blue 
)

Definition at line 558 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setMaterialSpecular()

int GameScript::setMaterialSpecular ( const Ogre::String &  materialName,
float  red,
float  green,
float  blue,
float  alpha 
)

Definition at line 541 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setMaterialTextureName()

int GameScript::setMaterialTextureName ( const Ogre::String &  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum,
const Ogre::String &  textureName 
)

Definition at line 609 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setMaterialTextureRotate()

int GameScript::setMaterialTextureRotate ( const Ogre::String &  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum,
float  rotation 
)

Definition at line 629 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setMaterialTextureScale()

int GameScript::setMaterialTextureScale ( const Ogre::String &  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum,
float  u,
float  v 
)

Definition at line 667 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setMaterialTextureScroll()

int GameScript::setMaterialTextureScroll ( const Ogre::String &  materialName,
int  techniqueNum,
int  passNum,
int  textureUnitNum,
float  sx,
float  sy 
)

Definition at line 648 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setPersonPosition()

void GameScript::setPersonPosition ( const Ogre::Vector3 &  vec)

sets the character position

Parameters
vecposition vector on the terrain

Definition at line 114 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setPersonRotation()

void GameScript::setPersonRotation ( const Ogre::Radian &  rot)

sets the character rotation

Parameters
rotthe character rotation

Definition at line 143 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setRegisteredEventsMask()

void GameScript::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

Definition at line 317 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setTimeDiff()

void GameScript::setTimeDiff ( float  diff)

Definition at line 201 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setTrucksForcedAwake()

void GameScript::setTrucksForcedAwake ( bool  forceActive)

Definition at line 104 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ setWaterHeight()

void GameScript::setWaterHeight ( float  value)

sets the base water height

Parameters
valuebase height in meters

Definition at line 211 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ showChooser()

void GameScript::showChooser ( const Ogre::String &  type,
const Ogre::String &  instance,
const Ogre::String &  box 
)

Definition at line 348 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ showMessageBox()

void GameScript::showMessageBox ( Ogre::String &  title,
Ogre::String &  text,
bool  use_btn1,
Ogre::String &  btn1_text,
bool  allow_close,
bool  use_btn2,
Ogre::String &  btn2_text 
)

Definition at line 1314 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ spawnObject()

void GameScript::spawnObject ( const Ogre::String &  objectName,
const Ogre::String &  instanceName,
const Ogre::Vector3 &  pos,
const Ogre::Vector3 &  rot,
const Ogre::String &  eventhandler,
bool  uniquifyMaterials 
)

This spawns a static terrain object (.ODEF file)

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)
uniquifyMaterialsSet this to true if you need to uniquify the materials

Definition at line 418 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ spawnTruck()

ActorPtr GameScript::spawnTruck ( Ogre::String &  truckName,
Ogre::Vector3 &  pos,
Ogre::Vector3 &  rot 
)

Definition at line 1046 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ spawnTruckAI()

ActorPtr GameScript::spawnTruckAI ( Ogre::String &  truckName,
Ogre::Vector3 &  pos,
Ogre::String &  truckSectionConfig,
std::string &  truckSkin,
int  x 
)

Definition at line 1055 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ startTimer()

void GameScript::startTimer ( int  id)

Definition at line 196 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ stopTimer()

void GameScript::stopTimer ( )

Definition at line 191 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ unRegisterEvent()

void GameScript::unRegisterEvent ( int  eventValue)

unregisters from receiving event.

Parameters
eventValue
See also
enum scriptEvents

Definition at line 297 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ updateDirectionArrow()

void GameScript::updateDirectionArrow ( Ogre::String &  text,
Ogre::Vector3 &  vec 
)

set direction arrow

Parameters
texttext to be displayed. "" to hide the text

Definition at line 333 of file GameScript.cpp.

+ Here is the call graph for this function:

◆ useOnlineAPI()

int GameScript::useOnlineAPI ( const Ogre::String &  apiquery,
const AngelScript::CScriptDictionary &  dict,
Ogre::String &  result 
)

Definition at line 806 of file GameScript.cpp.

+ Here is the call graph for this function:

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