Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
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)
 
float getTime ()
 returns the time in seconds since the game was started
 
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.
 
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.
 
bool pushMessage (MsgType type, AngelScript::CScriptDictionary *dict)
 Pushes a message to internal message queue.
 
bool checkResourceExists (const std::string &filename, const std::string &resource_group)
 Checks if the resource file exists in the given group.
 
bool deleteResource (const std::string &filename, const std::string &resource_group)
 Deletes a resource from the given group.
 
std::string loadTextResourceAsString (const std::string &filename, const std::string &resource_group)
 Loads a text file resource as string.
 
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.
 
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.
 
Ogre::Image loadImageResource (const std::string &filename, const std::string &resource_group)
 Loads an image in any format recognized by OGRE.
 
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).
 
GUI
void flashMessage (Ogre::String &txt, float time, float charHeight)
 DEPRECATED: use message() shows a message to the user.
 
void message (Ogre::String &txt, Ogre::String &icon)
 shows a message to the user over the console system
 
int getChatFontSize ()
 OBSOLETE, returns 0;.
 
void setChatFontSize (int size)
 OBSOLETE, does nothing.
 
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
 
void hideDirectionArrow ()
 
bool getScreenPosFromWorldPos (Ogre::Vector3 const &world_pos, Ogre::Vector2 &out_screen_pos)
 
Ogre::Vector2 getDisplaySize ()
 Gets screen size in pixels.
 
Ogre::Vector2 getMouseScreenPosition ()
 Gets mouse position in pixels.
 
Script management
void registerForEvent (int eventValue)
 registers for a new event to be received by the scripting system
 
void unRegisterEvent (int eventValue)
 unregisters from receiving event.
 
BitMask_t getRegisteredEventsMask (ScriptUnitID_t nid)
 Gets event mask for a specific running script.
 
void setRegisteredEventsMask (ScriptUnitID_t nid, BitMask_t eventMask)
 Overwrites event mask for a specific running script.
 
ScriptRetCode_t addScriptFunction (const Ogre::String &arg, ScriptUnitID_t nid)
 Adds a global function to the script (Wrapper for ScriptEngine::addFunction)
 
ScriptRetCode_t scriptFunctionExists (const Ogre::String &arg, ScriptUnitID_t nid)
 Checks if a global function exists in the script (Wrapper for ScriptEngine::functionExists)
 
ScriptRetCode_t deleteScriptFunction (const Ogre::String &arg, ScriptUnitID_t nid)
 Deletes a global function from the script (Wrapper for ScriptEngine::deleteFunction)
 
ScriptRetCode_t addScriptVariable (const Ogre::String &arg, ScriptUnitID_t nid)
 Adds a global variable to the script (Wrapper for ScriptEngine::addVariable)
 
ScriptRetCode_t scriptVariableExists (const Ogre::String &arg, ScriptUnitID_t nid)
 Adds a global variable to the script (Wrapper for ScriptEngine::variableExists)
 
ScriptRetCode_t deleteScriptVariable (const Ogre::String &arg, ScriptUnitID_t nid)
 Deletes a global variable from the script (Wrapper for ScriptEngine::deleteVariable)
 
ScriptRetCode_t getScriptVariable (const Ogre::String &varName, void *ref, int refTypeId, ScriptUnitID_t nid)
 Retrieves a memory address of a global variable in any script.
 
void clearEventCache ()
 
int sendGameCmd (const Ogre::String &message)
 Multiplayer only: sends AngelScript snippet to all players.
 
AngelScript::CScriptArray * getRunningScripts ()
 Returns array<int> with active ScriptUnitIDs; check agains global var thisScript or use getScriptDetails() to get name etc...
 
AngelScript::CScriptDictionary * getScriptDetails (ScriptUnitID_t nid)
 Returns all info about running script; obtain the NID from getRunningScripts(), global var thisScript or event callbacks:
 
Terrain
void loadTerrain (const Ogre::String &terrain)
 
int getLoadedTerrain (Ogre::String &result)
 gets the name of current terrain.
 
bool getCaelumAvailable ()
 
Ogre::String getCaelumTime ()
 gets the time of the day in seconds
 
void setCaelumTime (float value)
 sets the time of the day in seconds
 
float getGravity ()
 returns the currently set upo gravity
 
void setGravity (float value)
 sets the gravity terrain wide.
 
float getGroundHeight (Ogre::Vector3 &v)
 Gets terrain height at given coordinates.
 
float getWaterHeight ()
 returns the current base water level (without waves)
 
void setWaterHeight (float value)
 sets the base water height
 
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)
 
void moveObjectVisuals (const Ogre::String &instanceName, const Ogre::Vector3 &pos)
 This moves an object to a new position.
 
void destroyObject (const Ogre::String &instanceName)
 This destroys an object.
 
AngelScript::CScriptArray * getEditorObjects ()
 Returns array<TerrainEditorObjectClassPtr@> with all static objects on map (from any source).
 
bool getMousePositionOnTerrain (Ogre::Vector3 &out_pos)
 Calculates mouse cursor position on terrain.
 
AngelScript::CScriptArray * getMousePointedMovableObjects ()
 Returns array<Ogre::MovableObjects@> in no particular order.
 
TerrainPtr getTerrain ()
 
Character
Ogre::Vector3 getPersonPosition ()
 
void setPersonPosition (const Ogre::Vector3 &vec)
 sets the character position
 
void movePerson (const Ogre::Vector3 &vec)
 moves the person relative
 
void setPersonRotation (const Ogre::Radian &rot)
 sets the character rotation
 
Ogre::Radian getPersonRotation ()
 gets the character rotation
 
Actors
void activateAllVehicles ()
 
void setTrucksForcedAwake (bool forceActive)
 
void boostCurrentTruck (float factor)
 
ActorPtr getCurrentTruck ()
 returns the current selected truck, 0 if in person mode
 
ActorPtr getTruckByNum (int num)
 returns a truck by index, get max index by calling getNumTrucks
 
AngelScript::CScriptArray * getAllTrucks ()
 returns an array of all currently existing actors.
 
int getCurrentTruckNumber ()
 returns the current truck number.
 
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)
 
ActorPtr getTruckRemotelyReceivingCommands ()
 Actors with 'importcommands' flag will remotely respond to command keys when the player is close enough (works both on foot and in vehicles).
 
ActorInstanceID_t getActorNextInstanceId ()
 Returns an unused (not reused) ID to use with MSG_SIM_SPAWN_ACTOR_REQUESTED; see game.pushMessage().
 
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().
 
FreeBeamGfxID_t getFreeBeamGfxNextId ()
 Returns an unused (not reused) ID to use with MSG_SIM_ADD_FREEBEAMGFX_REQUESTED; see game.pushMessage().
 
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.
 
void setCameraDirection (const Ogre::Vector3 &vec)
 Sets the camera's direction vector.
 
void setCameraOrientation (const Ogre::Quaternion &q)
 Sets the camera's orientation.
 
void setCameraRoll (float angle)
 Rolls the camera anticlockwise, around its local z axis.
 
void setCameraYaw (float angle)
 Rotates the camera anticlockwise around it's local y axis.
 
void setCameraPitch (float angle)
 Pitches the camera up/down anticlockwise around it's local z axis.
 
Ogre::Vector3 getCameraPosition ()
 Retrieves the camera's position.
 
Ogre::Vector3 getCameraDirection ()
 Gets the camera's direction.
 
Ogre::Quaternion getCameraOrientation ()
 Gets the camera's orientation.
 
void cameraLookAt (const Ogre::Vector3 &targetPoint)
 Points the camera at a location in worldspace.
 
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.
 
bool HavePlayerAvatar (const char *func_name)
 Helper; Check if local Character instance exists, log warning if not.
 
bool HaveMainCamera (const char *func_name)
 Helper; Check if main camera exists, log warning if not.
 
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.
 
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)
 

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 100 of file GameScript.cpp.

◆ addScriptFunction()

int GameScript::addScriptFunction ( const Ogre::String &  arg,
ScriptUnitID_t  nid 
)

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

Parameters
argA declaration for the function.

Definition at line 979 of file GameScript.cpp.

◆ addScriptVariable()

int GameScript::addScriptVariable ( const Ogre::String &  arg,
ScriptUnitID_t  nid 
)

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

Parameters
argA declaration for the variable.

Definition at line 994 of file GameScript.cpp.

◆ addWaypoint()

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

Definition at line 1172 of file GameScript.cpp.

◆ backToMenu()

void GameScript::backToMenu ( )

Definition at line 1372 of file GameScript.cpp.

◆ boostCurrentTruck()

void GameScript::boostCurrentTruck ( float  factor)

Definition at line 968 of file GameScript.cpp.

◆ 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 828 of file GameScript.cpp.

◆ 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 2131 of file GameScript.cpp.

◆ 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 1916 of file GameScript.cpp.

◆ clearEventCache()

void GameScript::clearEventCache ( )

Definition at line 739 of file GameScript.cpp.

◆ 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 1906 of file GameScript.cpp.

◆ createSoundScriptInstance()

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

Definition at line 1911 of file GameScript.cpp.

◆ 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 2001 of file GameScript.cpp.

◆ 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 1934 of file GameScript.cpp.

◆ deleteScriptFunction()

int GameScript::deleteScriptFunction ( const Ogre::String &  arg,
ScriptUnitID_t  nid 
)

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

Parameters
argA declaration for the function.

Definition at line 989 of file GameScript.cpp.

◆ deleteScriptVariable()

int GameScript::deleteScriptVariable ( const Ogre::String &  arg,
ScriptUnitID_t  nid 
)

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

Parameters
argA declaration for the variable.

Definition at line 1004 of file GameScript.cpp.

◆ 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 426 of file GameScript.cpp.

◆ 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 952 of file GameScript.cpp.

◆ 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 2029 of file GameScript.cpp.

◆ flashMessage()

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

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

Definition at line 329 of file GameScript.cpp.

◆ getActorNextInstanceId()

ActorInstanceID_t GameScript::getActorNextInstanceId ( )

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

Definition at line 1878 of file GameScript.cpp.

◆ getAIMode()

int GameScript::getAIMode ( )

Definition at line 1272 of file GameScript.cpp.

◆ getAIRepeatTimes()

int GameScript::getAIRepeatTimes ( )

Definition at line 1266 of file GameScript.cpp.

◆ getAIVehicleCount()

int GameScript::getAIVehicleCount ( )

Definition at line 1200 of file GameScript.cpp.

◆ getAIVehicleDistance()

int GameScript::getAIVehicleDistance ( )

Definition at line 1206 of file GameScript.cpp.

◆ getAIVehicleName()

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

Definition at line 1224 of file GameScript.cpp.

◆ getAIVehiclePositionScheme()

int GameScript::getAIVehiclePositionScheme ( )

Definition at line 1212 of file GameScript.cpp.

◆ getAIVehicleSectionConfig()

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

Definition at line 1238 of file GameScript.cpp.

◆ getAIVehicleSkin()

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

Definition at line 1252 of file GameScript.cpp.

◆ getAIVehicleSpeed()

int GameScript::getAIVehicleSpeed ( )

Definition at line 1218 of file GameScript.cpp.

◆ getAllSoundScriptInstances()

AngelScript::CScriptArray * GameScript::getAllSoundScriptInstances ( )

Definition at line 1901 of file GameScript.cpp.

◆ getAllSoundScriptTemplates()

CScriptArray * GameScript::getAllSoundScriptTemplates ( )

Definition at line 1891 of file GameScript.cpp.

◆ getAllTrucks()

AngelScript::CScriptArray * GameScript::getAllTrucks ( )

returns an array of all currently existing actors.

Returns
array<BeamClass@>

Definition at line 1158 of file GameScript.cpp.

◆ getAvgFPS()

float GameScript::getAvgFPS ( )

Definition at line 1388 of file GameScript.cpp.

◆ getCaelumAvailable()

bool GameScript::getCaelumAvailable ( )

Definition at line 182 of file GameScript.cpp.

◆ getCaelumTime()

String GameScript::getCaelumTime ( )

gets the time of the day in seconds

Returns
string with HH::MM::SS format

Definition at line 160 of file GameScript.cpp.

◆ getCameraDirection()

Vector3 GameScript::getCameraDirection ( )

Gets the camera's direction.

Returns
A vector representing the direction of the camera

Definition at line 809 of file GameScript.cpp.

◆ getCameraOrientation()

Quaternion GameScript::getCameraOrientation ( )

Gets the camera's orientation.

Returns
A quaternion representing the orientation of the camera

Definition at line 820 of file GameScript.cpp.

◆ getCameraPosition()

Vector3 GameScript::getCameraPosition ( )

Retrieves the camera's position.

Returns
The current position of the camera

Definition at line 801 of file GameScript.cpp.

◆ getChatFontSize()

int GameScript::getChatFontSize ( )

OBSOLETE, returns 0;.

Definition at line 344 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.

◆ getCurrentTruckAI()

VehicleAIPtr GameScript::getCurrentTruckAI ( )

Definition at line 1065 of file GameScript.cpp.

◆ 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.

◆ getDisplaySize()

Ogre::Vector2 GameScript::getDisplaySize ( )

Gets screen size in pixels.

Definition at line 525 of file GameScript.cpp.

◆ getEditorObjects()

AngelScript::CScriptArray * GameScript::getEditorObjects ( )

Returns array<TerrainEditorObjectClassPtr@> with all static objects on map (from any source).

Definition at line 402 of file GameScript.cpp.

◆ getFPS()

float GameScript::getFPS ( )

Definition at line 1383 of file GameScript.cpp.

◆ getFreeBeamGfxNextId()

FreeBeamGfxID_t GameScript::getFreeBeamGfxNextId ( )

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

Definition at line 1883 of file GameScript.cpp.

◆ 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 1873 of file GameScript.cpp.

◆ 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.

◆ getGroundHeight()

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

Gets terrain height at given coordinates.

Definition at line 224 of file GameScript.cpp.

◆ 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 721 of file GameScript.cpp.

◆ getMousePointedMovableObjects()

CScriptArray * GameScript::getMousePointedMovableObjects ( )

Returns array<Ogre::MovableObjects@> in no particular order.

Definition at line 1426 of file GameScript.cpp.

◆ 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 1393 of file GameScript.cpp.

◆ getMouseScreenPosition()

Ogre::Vector2 GameScript::getMouseScreenPosition ( )

Gets mouse position in pixels.

Definition at line 531 of file GameScript.cpp.

◆ getNumTrucksByFlag()

int GameScript::getNumTrucksByFlag ( int  flag)

Definition at line 268 of file GameScript.cpp.

◆ getPersonPosition()

Vector3 GameScript::getPersonPosition ( )

Definition at line 128 of file GameScript.cpp.

◆ getPersonRotation()

Radian GameScript::getPersonRotation ( )

gets the character rotation

Returns
character rotation

Definition at line 152 of file GameScript.cpp.

◆ 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 315 of file GameScript.cpp.

◆ 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 1027 of file GameScript.cpp.

◆ getSceneManager()

Ogre::SceneManager * GameScript::getSceneManager ( )

Definition at line 1442 of file GameScript.cpp.

◆ 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 510 of file GameScript.cpp.

◆ 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 1037 of file GameScript.cpp.

◆ getScriptVariable()

int GameScript::getScriptVariable ( const Ogre::String &  varName,
void *  ref,
int  refTypeId,
ScriptUnitID_t  nid 
)

Retrieves a memory address of a global variable in any script.

Parameters
nidScriptUnitID, ID of the running script, obtain one from global var thisScript or game.getRunningScripts()
varNameName of the variable. Type must match the reference type.
refPointer to the variable's memory address; To be registered as variable-type parameter ?&out
refTypeIdType of the reference; To be registered as variable-type parameter ?&out
Returns
0 on success, negative number on error.

Definition at line 1009 of file GameScript.cpp.

◆ getSoundScriptTemplate()

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

Definition at line 1896 of file GameScript.cpp.

◆ getTerrain()

RoR::TerrainPtr GameScript::getTerrain ( )

Definition at line 734 of file GameScript.cpp.

◆ getTextureUnitState()

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

Definition at line 605 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 110 of file GameScript.cpp.

◆ getTruckAIByNum()

VehicleAIPtr GameScript::getTruckAIByNum ( int  num)

Definition at line 1075 of file GameScript.cpp.

◆ 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.

◆ getTruckRemotelyReceivingCommands()

ActorPtr GameScript::getTruckRemotelyReceivingCommands ( )

Actors with 'importcommands' flag will remotely respond to command keys when the player is close enough (works both on foot and in vehicles).

Definition at line 285 of file GameScript.cpp.

◆ 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.

◆ getWaypoints()

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

Definition at line 1135 of file GameScript.cpp.

◆ getWaypointsSpeed()

AngelScript::CScriptArray * GameScript::getWaypointsSpeed ( )

Definition at line 1181 of file GameScript.cpp.

◆ HaveMainCamera()

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

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

Definition at line 2121 of file GameScript.cpp.

◆ HavePlayerAvatar()

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

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

Definition at line 2111 of file GameScript.cpp.

◆ HaveSimTerrain()

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

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

Definition at line 2101 of file GameScript.cpp.

◆ hideDirectionArrow()

void GameScript::hideDirectionArrow ( )

Definition at line 505 of file GameScript.cpp.

◆ 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 2060 of file GameScript.cpp.

◆ loadTerrain()

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

Definition at line 123 of file GameScript.cpp.

◆ 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 1953 of file GameScript.cpp.

◆ log()

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

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

Parameters
msgstring to log

Definition at line 81 of file GameScript.cpp.

◆ logFormat()

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

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

Parameters
msgstring to log

Definition at line 86 of file GameScript.cpp.

◆ message()

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

shows a message to the user over the console system

Definition at line 334 of file GameScript.cpp.

◆ 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 437 of file GameScript.cpp.

◆ movePerson()

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

moves the person relative

Parameters
vectranslation vector

Definition at line 136 of file GameScript.cpp.

◆ 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 947 of file GameScript.cpp.

◆ 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 1447 of file GameScript.cpp.

◆ quitGame()

void GameScript::quitGame ( )

Definition at line 1378 of file GameScript.cpp.

◆ rangeRandom()

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

Definition at line 716 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 291 of file GameScript.cpp.

◆ removeVehicle()

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

Definition at line 393 of file GameScript.cpp.

◆ repairVehicle()

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

Definition at line 388 of file GameScript.cpp.

◆ scriptFunctionExists()

int GameScript::scriptFunctionExists ( const Ogre::String &  arg,
ScriptUnitID_t  nid 
)

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

Parameters
argA declaration for the function.

Definition at line 984 of file GameScript.cpp.

◆ scriptVariableExists()

int GameScript::scriptVariableExists ( const Ogre::String &  arg,
ScriptUnitID_t  nid 
)

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

Parameters
argA declaration for the variable.

Definition at line 999 of file GameScript.cpp.

◆ sendGameCmd()

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

Multiplayer only: sends AngelScript snippet to all players.

Definition at line 1014 of file GameScript.cpp.

◆ 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 2078 of file GameScript.cpp.

◆ setAIMode()

void GameScript::setAIMode ( int  mode)

Definition at line 1349 of file GameScript.cpp.

◆ setAIRepeatTimes()

void GameScript::setAIRepeatTimes ( int  times)

Definition at line 1344 of file GameScript.cpp.

◆ setAIVehicleCount()

void GameScript::setAIVehicleCount ( int  count)

Definition at line 1280 of file GameScript.cpp.

◆ setAIVehicleDistance()

void GameScript::setAIVehicleDistance ( int  dist)

Definition at line 1285 of file GameScript.cpp.

◆ setAIVehicleName()

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

Definition at line 1300 of file GameScript.cpp.

◆ setAIVehiclePositionScheme()

void GameScript::setAIVehiclePositionScheme ( int  scheme)

Definition at line 1290 of file GameScript.cpp.

◆ setAIVehicleSectionConfig()

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

Definition at line 1312 of file GameScript.cpp.

◆ setAIVehicleSkin()

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

Definition at line 1328 of file GameScript.cpp.

◆ setAIVehicleSpeed()

void GameScript::setAIVehicleSpeed ( int  speed)

Definition at line 1295 of file GameScript.cpp.

◆ setBestLapTime()

void GameScript::setBestLapTime ( float  time)

Definition at line 207 of file GameScript.cpp.

◆ setCaelumTime()

void GameScript::setCaelumTime ( float  value)

sets the time of the day in seconds

Parameters
valueday time in seconds

Definition at line 172 of file GameScript.cpp.

◆ 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 761 of file GameScript.cpp.

◆ 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 769 of file GameScript.cpp.

◆ 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 785 of file GameScript.cpp.

◆ setCameraPosition()

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

Sets the camera's position.

Parameters
posThe new position of the camera.

Definition at line 753 of file GameScript.cpp.

◆ setCameraRoll()

void GameScript::setCameraRoll ( float  angle)

Rolls the camera anticlockwise, around its local z axis.

Parameters
angleThe roll-angle

Definition at line 793 of file GameScript.cpp.

◆ setCameraYaw()

void GameScript::setCameraYaw ( float  angle)

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

Parameters
angleThe yaw-angle

Definition at line 777 of file GameScript.cpp.

◆ setChatFontSize()

void GameScript::setChatFontSize ( int  size)

OBSOLETE, does nothing.

Definition at line 349 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.

◆ setMaterialAmbient()

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

Definition at line 537 of file GameScript.cpp.

◆ setMaterialDiffuse()

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

Definition at line 554 of file GameScript.cpp.

◆ setMaterialEmissive()

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

Definition at line 588 of file GameScript.cpp.

◆ setMaterialSpecular()

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

Definition at line 571 of file GameScript.cpp.

◆ setMaterialTextureName()

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

Definition at line 639 of file GameScript.cpp.

◆ setMaterialTextureRotate()

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

Definition at line 659 of file GameScript.cpp.

◆ setMaterialTextureScale()

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

Definition at line 697 of file GameScript.cpp.

◆ setMaterialTextureScroll()

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

Definition at line 678 of file GameScript.cpp.

◆ setPersonPosition()

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

sets the character position

Parameters
vecposition vector on the terrain

Definition at line 115 of file GameScript.cpp.

◆ setPersonRotation()

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

sets the character rotation

Parameters
rotthe character rotation

Definition at line 144 of file GameScript.cpp.

◆ 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 323 of file GameScript.cpp.

◆ setTimeDiff()

void GameScript::setTimeDiff ( float  diff)

Definition at line 202 of file GameScript.cpp.

◆ setTrucksForcedAwake()

void GameScript::setTrucksForcedAwake ( bool  forceActive)

Definition at line 105 of file GameScript.cpp.

◆ setWaterHeight()

void GameScript::setWaterHeight ( float  value)

sets the base water height

Parameters
valuebase height in meters

Definition at line 212 of file GameScript.cpp.

◆ showChooser()

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

Definition at line 354 of file GameScript.cpp.

◆ 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 1354 of file GameScript.cpp.

◆ 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 448 of file GameScript.cpp.

◆ spawnTruck()

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

Definition at line 1086 of file GameScript.cpp.

◆ spawnTruckAI()

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

Definition at line 1095 of file GameScript.cpp.

◆ startTimer()

void GameScript::startTimer ( int  id)

Definition at line 197 of file GameScript.cpp.

◆ stopTimer()

void GameScript::stopTimer ( )

Definition at line 192 of file GameScript.cpp.

◆ unRegisterEvent()

void GameScript::unRegisterEvent ( int  eventValue)

unregisters from receiving event.

Parameters
eventValue
See also
enum scriptEvents

Definition at line 303 of file GameScript.cpp.

◆ 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 339 of file GameScript.cpp.

◆ useOnlineAPI()

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

Definition at line 836 of file GameScript.cpp.


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