RigsofRods
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GameScript.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2020 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
25 
26 #pragma once
27 
28 #include "Application.h"
29 
30 #include <angelscript.h>
31 #include <scriptdictionary/scriptdictionary.h>
32 
33 namespace RoR {
34 
37 
42 {
43 public:
44  // PLEASE maintain the same order as in GameScriptAngelscript.cpp!
45 
48 
53  void log(const Ogre::String& msg);
54 
59  float getTime();
60 
61  void backToMenu();
62  void quitGame();
63  float getFPS();
64  float getAvgFPS();
65  float rangeRandom(float from, float to);
66 
67  int useOnlineAPI(const Ogre::String& apiquery, const AngelScript::CScriptDictionary& dict, Ogre::String& result);
68 
72  void openUrlInDefaultBrowser(const std::string& url);
73 
77  void fetchUrlAsStringAsync(const std::string& url, const std::string& display_filename);
78 
83  bool pushMessage(MsgType type, AngelScript::CScriptDictionary* dict);
84 
90  bool checkResourceExists(const std::string& filename, const std::string& resource_group);
91 
96  bool deleteResource(const std::string& filename, const std::string& resource_group);
97 
104  std::string loadTextResourceAsString(const std::string& filename, const std::string& resource_group);
105 
115  bool createTextResourceFromString(const std::string& data, const std::string& filename, const std::string& resource_group, bool overwrite=false);
116 
117  Ogre::SceneManager* getSceneManager();
118 
122  AngelScript::CScriptArray* findResourceFileInfo(const std::string& resource_group, const std::string& pattern, bool dirs = false);
123 
127  Ogre::Image loadImageResource(const std::string& filename, const std::string& resource_group);
128 
132  bool serializeMeshResource(const std::string& filename, const std::string& resource_group, const Ogre::MeshPtr& mesh);
133 
135 
138 
143  void flashMessage(Ogre::String& txt, float time, float charHeight);
144 
148  void message(Ogre::String& txt, Ogre::String& icon);
149 
153  int getChatFontSize();
154 
158  void setChatFontSize(int size);
159 
160  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);
161 
162  void showChooser(const Ogre::String& type, const Ogre::String& instance, const Ogre::String& box);
163 
168  void updateDirectionArrow(Ogre::String& text, Ogre::Vector3& vec);
169 
170  void hideDirectionArrow();
171 
177  bool getScreenPosFromWorldPos(Ogre::Vector3 const& world_pos, Ogre::Vector2& out_screen_pos);
178 
182  Ogre::Vector2 getDisplaySize();
183 
187  Ogre::Vector2 getMouseScreenPosition();
188 
190 
193 
198  void registerForEvent(int eventValue);
199 
204  void unRegisterEvent(int eventValue);
205 
211 
217  void setRegisteredEventsMask(ScriptUnitID_t nid, BitMask_t eventMask);
218 
224  ScriptRetCode_t addScriptFunction(const Ogre::String& arg, ScriptUnitID_t nid);
225 
231  ScriptRetCode_t scriptFunctionExists(const Ogre::String& arg, ScriptUnitID_t nid);
232 
238  ScriptRetCode_t deleteScriptFunction(const Ogre::String& arg, ScriptUnitID_t nid);
239 
245  ScriptRetCode_t addScriptVariable(const Ogre::String& arg, ScriptUnitID_t nid);
246 
252  ScriptRetCode_t scriptVariableExists(const Ogre::String& arg, ScriptUnitID_t nid);
253 
259  ScriptRetCode_t deleteScriptVariable(const Ogre::String& arg, ScriptUnitID_t nid);
260 
269  ScriptRetCode_t getScriptVariable(const Ogre::String& varName, void *ref, int refTypeId, ScriptUnitID_t nid);
270 
271  void clearEventCache();
272 
276  int sendGameCmd(const Ogre::String& message);
277 
281  AngelScript::CScriptArray* getRunningScripts();
282 
291  AngelScript::CScriptDictionary* getScriptDetails(ScriptUnitID_t nid);
292 
294 
297 
298  void loadTerrain(const Ogre::String& terrain);
299 
304  int getLoadedTerrain(Ogre::String& result);
305 
306  bool getCaelumAvailable();
307 
312  Ogre::String getCaelumTime();
313 
318  void setCaelumTime(float value);
319 
324  float getGravity();
325 
330  void setGravity(float value);
331 
335  float getGroundHeight(Ogre::Vector3& v);
336 
341  float getWaterHeight();
342 
347  void setWaterHeight(float value);
348 
358  void spawnObject(const Ogre::String& objectName, const Ogre::String& instanceName, const Ogre::Vector3& pos, const Ogre::Vector3& rot, const Ogre::String& eventhandler, bool uniquifyMaterials);
359 
366  void moveObjectVisuals(const Ogre::String& instanceName, const Ogre::Vector3& pos);
367 
373  void destroyObject(const Ogre::String& instanceName);
374 
378  AngelScript::CScriptArray* getEditorObjects();
379 
385  bool getMousePositionOnTerrain(Ogre::Vector3& out_pos);
386 
390  AngelScript::CScriptArray* getMousePointedMovableObjects();
391 
393 
395 
398 
399  Ogre::Vector3 getPersonPosition();
400 
405  void setPersonPosition(const Ogre::Vector3& vec);
406 
411  void movePerson(const Ogre::Vector3& vec);
412 
417  void setPersonRotation(const Ogre::Radian& rot);
418 
423  Ogre::Radian getPersonRotation();
424 
426 
429 
430  void activateAllVehicles();
431 
432  void setTrucksForcedAwake(bool forceActive);
433 
434  //anglescript test
435  void boostCurrentTruck(float factor);
436 
442 
447  ActorPtr getTruckByNum(int num);
448 
453  AngelScript::CScriptArray* getAllTrucks();
454 
459  int getCurrentTruckNumber();
460 
461  ActorPtr spawnTruck(Ogre::String& truckName, Ogre::Vector3& pos, Ogre::Vector3& rot);
462 
463  void repairVehicle(const Ogre::String& instance, const Ogre::String& box, bool keepPosition);
464 
465  void removeVehicle(const Ogre::String& instance, const Ogre::String& box);
466 
467  int getNumTrucksByFlag(int flag);
468 
474 
479 
481 
484 
489 
491 
494 
495  ActorPtr spawnTruckAI(Ogre::String& truckName, Ogre::Vector3& pos, Ogre::String& truckSectionConfig, std::string& truckSkin, int x);
496  AngelScript::CScriptArray* getWaypoints(int x);
497  AngelScript::CScriptArray* getWaypointsSpeed();
498  void addWaypoint(const Ogre::Vector3& pos);
499  int getAIVehicleCount();
500  int getAIVehicleDistance();
502  int getAIVehicleSpeed();
503  Ogre::String getAIVehicleName(int x);
504  Ogre::String getAIVehicleSectionConfig(int x);
505  std::string getAIVehicleSkin(int x);
506  int getAIRepeatTimes();
507  int getAIMode();
509  VehicleAIPtr getTruckAIByNum(int num);
510  // AI: set
511  void setAIVehicleCount(int count);
512  void setAIVehicleDistance(int dist);
513  void setAIVehiclePositionScheme(int scheme);
514  void setAIVehicleSpeed(int speed);
515  void setAIVehicleName(int x, std::string name);
516  void setAIVehicleSectionConfig(int x, std::string config);
517  void setAIVehicleSkin(int x, std::string skin);
518  void setAIRepeatTimes(int times);
519  void setAIMode(int mode);
520 
522 
525 
530  void setCameraPosition(const Ogre::Vector3& pos);
531 
536  void setCameraDirection(const Ogre::Vector3& vec);
537 
542  void setCameraOrientation(const Ogre::Quaternion& q);
543 
548  void setCameraRoll(float angle);
549 
554  void setCameraYaw(float angle);
555 
560  void setCameraPitch(float angle);
561 
566  Ogre::Vector3 getCameraPosition();
567 
572  Ogre::Vector3 getCameraDirection();
573 
578  Ogre::Quaternion getCameraOrientation();
579 
588  void cameraLookAt(const Ogre::Vector3& targetPoint);
589 
591 
594 
595  void stopTimer();
596  void startTimer(int id);
597  void setTimeDiff(float diff);
598  void setBestLapTime(float time);
599 
601 
604 
605  int setMaterialAmbient(const Ogre::String& materialName, float red, float green, float blue);
606  int setMaterialDiffuse(const Ogre::String& materialName, float red, float green, float blue, float alpha);
607  int setMaterialSpecular(const Ogre::String& materialName, float red, float green, float blue, float alpha);
608  int setMaterialEmissive(const Ogre::String& materialName, float red, float green, float blue);
609  int setMaterialTextureName(const Ogre::String& materialName, int techniqueNum, int passNum, int textureUnitNum, const Ogre::String& textureName);
610  int setMaterialTextureRotate(const Ogre::String& materialName, int techniqueNum, int passNum, int textureUnitNum, float rotation);
611  int setMaterialTextureScroll(const Ogre::String& materialName, int techniqueNum, int passNum, int textureUnitNum, float sx, float sy);
612  int setMaterialTextureScale(const Ogre::String& materialName, int techniqueNum, int passNum, int textureUnitNum, float u, float v);
613 
615 
618 
619  AngelScript::CScriptArray* getAllSoundScriptTemplates();
620  SoundScriptTemplatePtr getSoundScriptTemplate(const std::string& name);
621  AngelScript::CScriptArray* getAllSoundScriptInstances();
622 
627  SoundPtr createSoundFromResource(const std::string& filename, const std::string& resource_group_name);
628 
629  SoundScriptInstancePtr createSoundScriptInstance(const std::string& template_name, int actor_instance_id /*= SoundScriptInstance::ACTOR_ID_UNKNOWN*/);
630 
632 
633 private:
634 
635  bool HaveSimTerrain(const char* func_name);
636  bool HavePlayerAvatar(const char* func_name);
637  bool HaveMainCamera(const char* func_name);
638  std::string CheckFileAccess(const char* func_name, const std::string& filename, const std::string& resource_group);
639  int getTextureUnitState(Ogre::TextureUnitState** tu, const Ogre::String materialName, int techniqueNum, int passNum, int textureUnitNum);
640 
645  void logFormat(const char* fmt, ...);
646 };
647 
649 
650 } // namespace RoR
RoR::GameScript::HavePlayerAvatar
bool HavePlayerAvatar(const char *func_name)
Helper; Check if local Character instance exists, log warning if not.
Definition: GameScript.cpp:2026
RoR::GameScript::getAIVehicleSkin
std::string getAIVehicleSkin(int x)
Definition: GameScript.cpp:1253
RoR::GameScript::getSoundScriptTemplate
SoundScriptTemplatePtr getSoundScriptTemplate(const std::string &name)
Definition: GameScript.cpp:1811
RoR::GameScript::getAllSoundScriptTemplates
AngelScript::CScriptArray * getAllSoundScriptTemplates()
Definition: GameScript.cpp:1806
RoR::GameScript::getScriptVariable
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.
Definition: GameScript.cpp:1010
RoR::GameScript::stopTimer
void stopTimer()
Definition: GameScript.cpp:192
RoR::GameScript::getTerrain
TerrainPtr getTerrain()
Definition: GameScript.cpp:735
RoR::GameScript::setCameraPosition
void setCameraPosition(const Ogre::Vector3 &pos)
Sets the camera's position.
Definition: GameScript.cpp:754
RoR::GameScript::sendGameCmd
int sendGameCmd(const Ogre::String &message)
Multiplayer only: sends AngelScript snippet to all players.
Definition: GameScript.cpp:1015
RoR::GameScript::setAIRepeatTimes
void setAIRepeatTimes(int times)
Definition: GameScript.cpp:1345
RoR::GameScript::setMaterialTextureScale
int setMaterialTextureScale(const Ogre::String &materialName, int techniqueNum, int passNum, int textureUnitNum, float u, float v)
Definition: GameScript.cpp:698
RoR::GameScript::getLoadedTerrain
int getLoadedTerrain(Ogre::String &result)
gets the name of current terrain.
Definition: GameScript.cpp:722
RoR::GameScript::getCurrentTruckNumber
int getCurrentTruckNumber()
returns the current truck number.
Definition: GameScript.cpp:280
RoR::GameScript::setMaterialTextureRotate
int setMaterialTextureRotate(const Ogre::String &materialName, int techniqueNum, int passNum, int textureUnitNum, float rotation)
Definition: GameScript.cpp:660
RoR::GameScript::setMaterialTextureScroll
int setMaterialTextureScroll(const Ogre::String &materialName, int techniqueNum, int passNum, int textureUnitNum, float sx, float sy)
Definition: GameScript.cpp:679
RoR::GameScript::getAIMode
int getAIMode()
Definition: GameScript.cpp:1273
RoR::GameScript::createSoundScriptInstance
SoundScriptInstancePtr createSoundScriptInstance(const std::string &template_name, int actor_instance_id)
Definition: GameScript.cpp:1826
RoR::GameScript::setCameraOrientation
void setCameraOrientation(const Ogre::Quaternion &q)
Sets the camera's orientation.
Definition: GameScript.cpp:770
RoR::GameScript::setRegisteredEventsMask
void setRegisteredEventsMask(ScriptUnitID_t nid, BitMask_t eventMask)
Overwrites event mask for a specific running script.
Definition: GameScript.cpp:324
RoR::GameScript::getTime
float getTime()
returns the time in seconds since the game was started
Definition: GameScript.cpp:110
RoR::GameScript::setWaterHeight
void setWaterHeight(float value)
sets the base water height
Definition: GameScript.cpp:212
RoR::GameScript::setPersonRotation
void setPersonRotation(const Ogre::Radian &rot)
sets the character rotation
Definition: GameScript.cpp:144
RoR::GameScript::setMaterialDiffuse
int setMaterialDiffuse(const Ogre::String &materialName, float red, float green, float blue, float alpha)
Definition: GameScript.cpp:555
RoR::GameScript::addScriptVariable
ScriptRetCode_t addScriptVariable(const Ogre::String &arg, ScriptUnitID_t nid)
Adds a global variable to the script (Wrapper for ScriptEngine::addVariable)
Definition: GameScript.cpp:995
RoR::GameScript::pushMessage
bool pushMessage(MsgType type, AngelScript::CScriptDictionary *dict)
Pushes a message to internal message queue.
Definition: GameScript.cpp:1448
RoR::GameScript::setCameraPitch
void setCameraPitch(float angle)
Pitches the camera up/down anticlockwise around it's local z axis.
Definition: GameScript.cpp:786
RoR::GameScript::getWaterHeight
float getWaterHeight()
returns the current base water level (without waves)
Definition: GameScript.cpp:233
RoR::GameScript::getAIVehicleDistance
int getAIVehicleDistance()
Definition: GameScript.cpp:1207
RoR::GameScript::updateDirectionArrow
void updateDirectionArrow(Ogre::String &text, Ogre::Vector3 &vec)
set direction arrow
Definition: GameScript.cpp:340
RoR::GameScript::getWaypointsSpeed
AngelScript::CScriptArray * getWaypointsSpeed()
Definition: GameScript.cpp:1182
RoR::GameScript::flashMessage
void flashMessage(Ogre::String &txt, float time, float charHeight)
DEPRECATED: use message() shows a message to the user.
Definition: GameScript.cpp:330
RoR::GameScript::setAIVehicleName
void setAIVehicleName(int x, std::string name)
Definition: GameScript.cpp:1301
RoR::ScriptRetCode_t
int ScriptRetCode_t
see enum RoR::ScriptRetCode - combines AngelScript codes and RoR internal codes.
Definition: ForwardDeclarations.h:88
RoR::GameScript::getNumTrucksByFlag
int getNumTrucksByFlag(int flag)
Definition: GameScript.cpp:269
RoR::GameScript::setAIVehicleSkin
void setAIVehicleSkin(int x, std::string skin)
Definition: GameScript.cpp:1329
RoR::GameScript::getCaelumAvailable
bool getCaelumAvailable()
Definition: GameScript.cpp:182
RoR::GameScript::activateAllVehicles
void activateAllVehicles()
Definition: GameScript.cpp:100
RoR::GameScript::setMaterialTextureName
int setMaterialTextureName(const Ogre::String &materialName, int techniqueNum, int passNum, int textureUnitNum, const Ogre::String &textureName)
Definition: GameScript.cpp:640
RoR::GameScript::getCurrentTruckAI
VehicleAIPtr getCurrentTruckAI()
Definition: GameScript.cpp:1066
RoR::GameScript::getMousePositionOnTerrain
bool getMousePositionOnTerrain(Ogre::Vector3 &out_pos)
Calculates mouse cursor position on terrain.
Definition: GameScript.cpp:1394
RoR::GameScript::getPersonPosition
Ogre::Vector3 getPersonPosition()
Definition: GameScript.cpp:128
RoR::GameScript::loadTerrain
void loadTerrain(const Ogre::String &terrain)
Definition: GameScript.cpp:123
RoR::GameScript::getTruckByNum
ActorPtr getTruckByNum(int num)
returns a truck by index, get max index by calling getNumTrucks
Definition: GameScript.cpp:264
RoR::GameScript::getSceneManager
Ogre::SceneManager * getSceneManager()
Definition: GameScript.cpp:1443
RoR::GameScript::HaveSimTerrain
bool HaveSimTerrain(const char *func_name)
Helper; Check if SimController instance exists, log warning if not.
Definition: GameScript.cpp:2016
RoR::GameScript::getGroundHeight
float getGroundHeight(Ogre::Vector3 &v)
Gets terrain height at given coordinates.
Definition: GameScript.cpp:225
RoR::GameScript::getAIVehicleName
Ogre::String getAIVehicleName(int x)
Definition: GameScript.cpp:1225
RoR::GameScript::getAIVehicleCount
int getAIVehicleCount()
Definition: GameScript.cpp:1201
RoR::GameScript::openUrlInDefaultBrowser
void openUrlInDefaultBrowser(const std::string &url)
Opens URL (must start with 'http://' or 'https://') in system's default web browser.
Definition: GameScript.cpp:948
RoR::GameScript::getWaypoints
AngelScript::CScriptArray * getWaypoints(int x)
Definition: GameScript.cpp:1136
RoR::GameScript::setCameraDirection
void setCameraDirection(const Ogre::Vector3 &vec)
Sets the camera's direction vector.
Definition: GameScript.cpp:762
RoR::GameScript::setAIVehiclePositionScheme
void setAIVehiclePositionScheme(int scheme)
Definition: GameScript.cpp:1291
RoR::GameScript::loadImageResource
Ogre::Image loadImageResource(const std::string &filename, const std::string &resource_group)
Loads an image in any format recognized by OGRE.
Definition: GameScript.cpp:1975
RoR::GameScript::startTimer
void startTimer(int id)
Definition: GameScript.cpp:197
RoR::GameScript::getAIRepeatTimes
int getAIRepeatTimes()
Definition: GameScript.cpp:1267
RoR::GameScript::getGravity
float getGravity()
returns the currently set upo gravity
Definition: GameScript.cpp:246
RefCountingObjectPtr< Terrain >
RoR::GameScript::getAvgFPS
float getAvgFPS()
Definition: GameScript.cpp:1389
RoR::GameScript::scriptFunctionExists
ScriptRetCode_t scriptFunctionExists(const Ogre::String &arg, ScriptUnitID_t nid)
Checks if a global function exists in the script (Wrapper for ScriptEngine::functionExists)
Definition: GameScript.cpp:985
RoR::GameScript::getMousePointedMovableObjects
AngelScript::CScriptArray * getMousePointedMovableObjects()
Returns array<Ogre::MovableObjects@> in no particular order.
Definition: GameScript.cpp:1427
RoR::GameScript::clearEventCache
void clearEventCache()
Definition: GameScript.cpp:740
RoR::GameScript::removeVehicle
void removeVehicle(const Ogre::String &instance, const Ogre::String &box)
Definition: GameScript.cpp:394
RoR::GameScript::showChooser
void showChooser(const Ogre::String &type, const Ogre::String &instance, const Ogre::String &box)
Definition: GameScript.cpp:355
RoR::GameScript::spawnObject
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)
Definition: GameScript.cpp:449
RoR::GameScript::getCurrentTruck
ActorPtr getCurrentTruck()
returns the current selected truck, 0 if in person mode
Definition: GameScript.cpp:241
RoR::GameScript::HaveMainCamera
bool HaveMainCamera(const char *func_name)
Helper; Check if main camera exists, log warning if not.
Definition: GameScript.cpp:2036
RoR::GameScript::boostCurrentTruck
void boostCurrentTruck(float factor)
Definition: GameScript.cpp:969
RoR::GameScript::getCaelumTime
Ogre::String getCaelumTime()
gets the time of the day in seconds
Definition: GameScript.cpp:160
RoR::ActorInstanceID_t
int ActorInstanceID_t
Unique sequentially generated ID of an actor in session. Use ActorManager::GetActorById()
Definition: ForwardDeclarations.h:38
RoR::GameScript::getCameraOrientation
Ogre::Quaternion getCameraOrientation()
Gets the camera's orientation.
Definition: GameScript.cpp:821
RoR::GameScript::getAIVehicleSpeed
int getAIVehicleSpeed()
Definition: GameScript.cpp:1219
RoR::GameScript::setMaterialSpecular
int setMaterialSpecular(const Ogre::String &materialName, float red, float green, float blue, float alpha)
Definition: GameScript.cpp:572
RoR::GameScript::message
void message(Ogre::String &txt, Ogre::String &icon)
shows a message to the user over the console system
Definition: GameScript.cpp:335
RoR::GameScript::getCameraPosition
Ogre::Vector3 getCameraPosition()
Retrieves the camera's position.
Definition: GameScript.cpp:802
RoR::GameScript::getAIVehicleSectionConfig
Ogre::String getAIVehicleSectionConfig(int x)
Definition: GameScript.cpp:1239
RoR::GameScript::setTimeDiff
void setTimeDiff(float diff)
Definition: GameScript.cpp:202
RoR::GameScript::findResourceFileInfo
AngelScript::CScriptArray * findResourceFileInfo(const std::string &resource_group, const std::string &pattern, bool dirs=false)
Proxy to Ogre::ResourceGroupManager::findResourceFileInfo(), see https://ogrecave....
Definition: GameScript.cpp:1944
RoR::GameScript::setGravity
void setGravity(float value)
sets the gravity terrain wide.
Definition: GameScript.cpp:256
RoR::GameScript::setBestLapTime
void setBestLapTime(float time)
Definition: GameScript.cpp:207
RoR::GameScript::setMaterialAmbient
int setMaterialAmbient(const Ogre::String &materialName, float red, float green, float blue)
Definition: GameScript.cpp:538
RoR::GameScript::showMessageBox
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)
Definition: GameScript.cpp:1355
RoR::GameScript::CheckFileAccess
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.
Definition: GameScript.cpp:2046
RoR::GameScript::useOnlineAPI
int useOnlineAPI(const Ogre::String &apiquery, const AngelScript::CScriptDictionary &dict, Ogre::String &result)
Definition: GameScript.cpp:837
RoR::FreeForceID_t
int FreeForceID_t
Unique sequentially generated ID of FreeForce; use ActorManager::GetFreeForceNextId().
Definition: ForwardDeclarations.h:67
RoR::GameScript::setPersonPosition
void setPersonPosition(const Ogre::Vector3 &vec)
sets the character position
Definition: GameScript.cpp:115
RoR::GameScript::destroyObject
void destroyObject(const Ogre::String &instanceName)
This destroys an object.
Definition: GameScript.cpp:427
RoR::GameScript::deleteScriptVariable
ScriptRetCode_t deleteScriptVariable(const Ogre::String &arg, ScriptUnitID_t nid)
Deletes a global variable from the script (Wrapper for ScriptEngine::deleteVariable)
Definition: GameScript.cpp:1005
RoR::GameScript::setCaelumTime
void setCaelumTime(float value)
sets the time of the day in seconds
Definition: GameScript.cpp:172
RoR::GameScript::getRegisteredEventsMask
BitMask_t getRegisteredEventsMask(ScriptUnitID_t nid)
Gets event mask for a specific running script.
Definition: GameScript.cpp:316
RoR::MsgType
MsgType
Global gameplay message loop, see struct Message in GameContext.h.
Definition: Application.h:74
RoR::GameScript::registerForEvent
void registerForEvent(int eventValue)
registers for a new event to be received by the scripting system
Definition: GameScript.cpp:292
Application.h
Central state/object manager and communications hub.
RoR::GameScript::setAIVehicleDistance
void setAIVehicleDistance(int dist)
Definition: GameScript.cpp:1286
RoR::GameScript::log
void log(const Ogre::String &msg)
writes a message to the games log (RoR.log)
Definition: GameScript.cpp:81
RoR::GameScript::getCameraDirection
Ogre::Vector3 getCameraDirection()
Gets the camera's direction.
Definition: GameScript.cpp:810
RoR::GameScript::setCameraYaw
void setCameraYaw(float angle)
Rotates the camera anticlockwise around it's local y axis.
Definition: GameScript.cpp:778
RoR::GameScript::spawnTruckAI
ActorPtr spawnTruckAI(Ogre::String &truckName, Ogre::Vector3 &pos, Ogre::String &truckSectionConfig, std::string &truckSkin, int x)
Definition: GameScript.cpp:1096
RoR::GameScript::getScriptDetails
AngelScript::CScriptDictionary * getScriptDetails(ScriptUnitID_t nid)
Returns all info about running script; obtain the NID from getRunningScripts(), global var thisScript...
Definition: GameScript.cpp:1038
RoR::GameScript::fetchUrlAsStringAsync
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_STAT...
Definition: GameScript.cpp:953
RoR::GameScript::serializeMeshResource
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).
Definition: GameScript.cpp:1993
RoR::GameScript::createTextResourceFromString
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.
Definition: GameScript.cpp:1916
RoR::GameScript::getActorNextInstanceId
ActorInstanceID_t getActorNextInstanceId()
Returns an unused (not reused) ID to use with MSG_SIM_SPAWN_ACTOR_REQUESTED; see game....
Definition: GameScript.cpp:1798
RoR::GameScript::getAllTrucks
AngelScript::CScriptArray * getAllTrucks()
returns an array of all currently existing actors.
Definition: GameScript.cpp:1159
RoR::GameScript::getPersonRotation
Ogre::Radian getPersonRotation()
gets the character rotation
Definition: GameScript.cpp:152
RoR::GameScript::getDisplaySize
Ogre::Vector2 getDisplaySize()
Gets screen size in pixels.
Definition: GameScript.cpp:526
RoR::GameScript::getChatFontSize
int getChatFontSize()
OBSOLETE, returns 0;.
Definition: GameScript.cpp:345
RoR::GameScript::setMaterialEmissive
int setMaterialEmissive(const Ogre::String &materialName, float red, float green, float blue)
Definition: GameScript.cpp:589
RoR::GameScript::getEditorObjects
AngelScript::CScriptArray * getEditorObjects()
Returns array<TerrainEditorObjectClassPtr@> with all static objects on map (from any source).
Definition: GameScript.cpp:403
RoR::GameScript::getAllSoundScriptInstances
AngelScript::CScriptArray * getAllSoundScriptInstances()
Definition: GameScript.cpp:1816
RoR::GameScript::setAIVehicleSectionConfig
void setAIVehicleSectionConfig(int x, std::string config)
Definition: GameScript.cpp:1313
RoR::GameScript::hideDirectionArrow
void hideDirectionArrow()
Definition: GameScript.cpp:506
RoR::GameScript
Proxy class that can be called by script functions.
Definition: GameScript.h:41
instance
or anywhere else will not be considered a but parsed as regular data ! Each line is treated as values separated by separators Possible i e animators Multiline description Single instance
Definition: ReadMe.txt:53
RoR::GameScript::getTruckAIByNum
VehicleAIPtr getTruckAIByNum(int num)
Definition: GameScript.cpp:1076
RoR::GameScript::getRunningScripts
AngelScript::CScriptArray * getRunningScripts()
Returns array<int> with active ScriptUnitIDs; check agains global var thisScript or use getScriptDeta...
Definition: GameScript.cpp:1028
RoR::GameScript::moveObjectVisuals
void moveObjectVisuals(const Ogre::String &instanceName, const Ogre::Vector3 &pos)
This moves an object to a new position.
Definition: GameScript.cpp:438
RoR::GameScript::addWaypoint
void addWaypoint(const Ogre::Vector3 &pos)
Definition: GameScript.cpp:1173
RoR::GameScript::getFreeForceNextId
FreeForceID_t getFreeForceNextId()
Returns an unused (not reused) ID to use with MSG_SIM_ADD_FREEFORCE_REQUESTED; see game....
Definition: GameScript.cpp:1793
RoR::GameScript::getAIVehiclePositionScheme
int getAIVehiclePositionScheme()
Definition: GameScript.cpp:1213
RoR::GameScript::movePerson
void movePerson(const Ogre::Vector3 &vec)
moves the person relative
Definition: GameScript.cpp:136
RoR::GameScript::addScriptFunction
ScriptRetCode_t addScriptFunction(const Ogre::String &arg, ScriptUnitID_t nid)
Adds a global function to the script (Wrapper for ScriptEngine::addFunction)
Definition: GameScript.cpp:980
RoR::GameScript::setCameraRoll
void setCameraRoll(float angle)
Rolls the camera anticlockwise, around its local z axis.
Definition: GameScript.cpp:794
RoR::GameScript::deleteScriptFunction
ScriptRetCode_t deleteScriptFunction(const Ogre::String &arg, ScriptUnitID_t nid)
Deletes a global function from the script (Wrapper for ScriptEngine::deleteFunction)
Definition: GameScript.cpp:990
BitMask_t
uint32_t BitMask_t
Definition: BitFlags.h:7
RoR::GameScript::getTruckRemotelyReceivingCommands
ActorPtr getTruckRemotelyReceivingCommands()
Actors with 'importcommands' flag will remotely respond to command keys when the player is close enou...
Definition: GameScript.cpp:286
RoR::GameScript::checkResourceExists
bool checkResourceExists(const std::string &filename, const std::string &resource_group)
Checks if the resource file exists in the given group.
Definition: GameScript.cpp:1831
RoR::GameScript::getTextureUnitState
int getTextureUnitState(Ogre::TextureUnitState **tu, const Ogre::String materialName, int techniqueNum, int passNum, int textureUnitNum)
Definition: GameScript.cpp:606
RoR::ScriptUnitID_t
int ScriptUnitID_t
Unique sequentially generated ID of a loaded and running scriptin session. Use ScriptEngine::getScrip...
Definition: ForwardDeclarations.h:41
RoR::GameScript::setAIVehicleSpeed
void setAIVehicleSpeed(int speed)
Definition: GameScript.cpp:1296
RoR::GameScript::setTrucksForcedAwake
void setTrucksForcedAwake(bool forceActive)
Definition: GameScript.cpp:105
RoR::GameScript::createSoundFromResource
SoundPtr createSoundFromResource(const std::string &filename, const std::string &resource_group_name)
Definition: GameScript.cpp:1821
RoR::GameScript::setAIMode
void setAIMode(int mode)
Definition: GameScript.cpp:1350
RoR::GameScript::loadTextResourceAsString
std::string loadTextResourceAsString(const std::string &filename, const std::string &resource_group)
Loads a text file resource as string.
Definition: GameScript.cpp:1868
RoR::GameScript::getFPS
float getFPS()
Definition: GameScript.cpp:1384
RoR::GameScript::getScreenPosFromWorldPos
bool getScreenPosFromWorldPos(Ogre::Vector3 const &world_pos, Ogre::Vector2 &out_screen_pos)
Definition: GameScript.cpp:511
RoR::GameScript::repairVehicle
void repairVehicle(const Ogre::String &instance, const Ogre::String &box, bool keepPosition)
Definition: GameScript.cpp:389
RoR::GameScript::deleteResource
bool deleteResource(const std::string &filename, const std::string &resource_group)
Deletes a resource from the given group.
Definition: GameScript.cpp:1849
RoR
Definition: AppContext.h:36
x
float x
Definition: (ValueTypes) quaternion.h:5
RoR::GameScript::setChatFontSize
void setChatFontSize(int size)
OBSOLETE, does nothing.
Definition: GameScript.cpp:350
RoR::GameScript::quitGame
void quitGame()
Definition: GameScript.cpp:1379
RoR::GameScript::spawnTruck
ActorPtr spawnTruck(Ogre::String &truckName, Ogre::Vector3 &pos, Ogre::Vector3 &rot)
Definition: GameScript.cpp:1087
RoR::GameScript::backToMenu
void backToMenu()
Definition: GameScript.cpp:1373
RoR::GameScript::unRegisterEvent
void unRegisterEvent(int eventValue)
unregisters from receiving event.
Definition: GameScript.cpp:304
RoR::GameScript::cameraLookAt
void cameraLookAt(const Ogre::Vector3 &targetPoint)
Points the camera at a location in worldspace.
Definition: GameScript.cpp:829
RoR::GameScript::setAIVehicleCount
void setAIVehicleCount(int count)
Definition: GameScript.cpp:1281
RoR::GameScript::getMouseScreenPosition
Ogre::Vector2 getMouseScreenPosition()
Gets mouse position in pixels.
Definition: GameScript.cpp:532
RoR::GameScript::scriptVariableExists
ScriptRetCode_t scriptVariableExists(const Ogre::String &arg, ScriptUnitID_t nid)
Adds a global variable to the script (Wrapper for ScriptEngine::variableExists)
Definition: GameScript.cpp:1000
RoR::GameScript::logFormat
void logFormat(const char *fmt,...)
writes a message to the games log (RoR.log)
Definition: GameScript.cpp:86
RoR::GameScript::rangeRandom
float rangeRandom(float from, float to)
Definition: GameScript.cpp:717