|
RigsofRods
Soft-body Physics Simulation
|
Go to the documentation of this file.
28 #ifdef USE_ANGELSCRIPT
30 #define DEFAULT_TERRAIN_SCRIPT "default.as" // Used when map creator doesn't provide custom script.
40 #include "scriptdictionary/scriptdictionary.h"
41 #include "scriptbuilder/scriptbuilder.h"
51 inline void TRIGGER_EVENT_ASYNC(
scriptEvents type,
int arg1,
int arg2ex = 0,
int arg3ex = 0,
int arg4ex = 0, std::string arg5ex =
"", std::string arg6ex =
"", std::string arg7ex =
"", std::string arg8ex =
"")
137 ActorPtr associatedActor =
nullptr, std::string buffer =
"");
157 void triggerEvent(
scriptEvents eventnum,
int arg1=0,
int arg2ex=0,
int arg3ex=0,
int arg4ex=0, std::string arg5ex=
"", std::string arg6ex=
"", std::string arg7ex=
"", std::string arg8ex=
"");
211 int fireEvent(std::string instanceName,
float intensity);
226 void messageLogged(
const Ogre::String& message, Ogre::LogMessageLevel lml,
bool maskDebug,
const Ogre::String& logName,
bool& skipThisMessage);
228 inline void SLOG(
const char* msg) { this->
scriptLog->logMessage(msg); }
229 inline void SLOG(std::string msg) { this->
scriptLog->logMessage(msg); }
278 void msgCallback(
const AngelScript::asSMessageInfo* msg);
311 #else // USE_ANGELSCRIPT
312 inline void TRIGGER_EVENT_ASYNC(
scriptEvents type,
int arg1,
int arg2ex = 0,
int arg3ex = 0,
int arg4ex = 0, std::string arg5ex =
"", std::string arg6ex =
"", std::string arg7ex =
"", std::string arg8ex =
"")
315 #endif // USE_ANGELSCRIPT
Represents a loaded script and all associated resources/handles.
Game state manager and message-queue provider.
AngelScript::asIScriptFunction * frameStepFunctionPtr
script function pointer to the frameStep function
ScriptUnitMap const & getScriptUnits() const
void setEventsEnabled(bool val)
void msgCallback(const AngelScript::asSMessageInfo *msg)
Optional (but very recommended!) callback providing diagnostic info when things fail to start (most n...
void exceptionCallback(AngelScript::asIScriptContext *ctx)
Optional callback invoked when the script critically fails, allowing debugging.
This class represents the angelscript scripting interface.
std::string lsr_filename
Load from resource (file). If buffer is supplied, use this as display name only.
Args for eventCallbackEx() queued via MSG_SIM_SCRIPT_EVENT_TRIGGERED See descriptions at enum RoR::sc...
bool scriptUnitExists(ScriptUnitId_t unique_id)
Ogre::String composeModuleName(Ogre::String const &scriptName, ScriptCategory origin, ScriptUnitId_t id)
Packs name + important info to one string, for logging and reporting purposes.
const GetFuncFlags_t GETFUNCFLAG_OPTIONAL
Only logs warning if candidate is found, to help modder find a typo.
unsigned int eventMask
filter mask for script events
int setupScriptUnit(int unit_id)
Helper for loadScript(), does the actual building without worry about unit management.
static const NodeNum_t NODENUM_INVALID
int executeContextAndHandleErrors(ScriptUnitId_t nid)
Helper for executing any script function/snippet; registers Line/Exception callbacks (on demand) and ...
void TRIGGER_EVENT_ASYNC(scriptEvents type, int arg1, int arg2ex=0, int arg3ex=0, int arg4ex=0, std::string arg5ex="", std::string arg6ex="", std::string arg7ex="", std::string arg8ex="")
Asynchronously (via MSG_SIM_SCRIPT_EVENT_TRIGGERED) invoke script function eventCallbackEx(),...
const char * ScriptCategoryToString(ScriptCategory c)
int addVariable(const Ogre::String &arg)
Adds a global variable to the script.
int executeString(Ogre::String command)
executes a string (useful for the console)
AngelScript::asIScriptEngine * getEngine()
std::string lsr_buffer
Load from memory buffer.
void setForwardScriptLogToConsole(bool doForward)
void forwardExceptionAsScriptEvent(const std::string &from)
Forwards useful info from C++ try{}catch{} exceptions to script in the form of game event.
BitMask_t GetFuncFlags_t
Flags for RoR::ScriptEngine::getFunctionByDeclAndLogCandidates()
ScriptUnitId_t loadScript(Ogre::String scriptname, ScriptCategory category=ScriptCategory::TERRAIN, ActorPtr associatedActor=nullptr, std::string buffer="")
Loads a script.
void queueStringForExecution(const Ogre::String command)
Queues a string for execution.
void framestep(Ogre::Real dt)
Calls the script's framestep function to be able to use timed things inside the script.
int deleteVariable(const Ogre::String &arg)
Deletes a global variable from the script.
const std::string GETFUNC_DEFAULTEVENTCALLBACK_NAME
static const ScriptUnitId_t SCRIPTUNITID_INVALID
ScriptCategory lsr_category
bool prepareContextAndHandleErrors(ScriptUnitId_t nid, int asFunctionID)
Helper for executing any script function/snippet; does asIScriptContext::Prepare() and reports any er...
int ActorInstanceID_t
Unique sequentially generated ID of an actor in session. Use ActorManager::GetActorById()
void init()
This function initialzies the engine and registeres all types.
uint16_t NodeNum_t
Node position within Actor::ar_nodes; use RoR::NODENUM_INVALID as empty value.
void unloadScript(ScriptUnitId_t unique_id)
Unloads a script.
static const ActorInstanceID_t ACTORINSTANCEID_INVALID
ScriptCategory scriptCategory
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
int ScriptUnitId_t
Unique sequentially generated ID of a loaded and running scriptin session. Use ScriptEngine::getScrip...
void envokeCallback(int functionId, eventsource_t *source, NodeNum_t nodenum=NODENUM_INVALID, int type=0)
AngelScript::asIScriptFunction * defaultEventCallbackFunctionPtr
script function pointer for spawner events
void lineCallback(AngelScript::asIScriptContext *ctx)
Optional callback which receives diagnostic info for every executed statement.
ActorInstanceID_t lsr_associated_actor
For ScriptCategory::ACTOR.
Central state/object manager and communications hub.
ScriptUnitId_t m_currently_executing_script_unit
GameContext * GetGameContext()
scriptEvents m_currently_executing_event_trigger
bool m_events_enabled
Hack to enable fast shutdown without cleanup.
void triggerEvent(scriptEvents eventnum, int arg1=0, int arg2ex=0, int arg3ex=0, int arg4ex=0, std::string arg5ex="", std::string arg6ex="", std::string arg7ex="", std::string arg8ex="")
triggers an event; Not to be used by the end-user.
AngelScript::asIScriptFunction * getFunctionByDeclAndLogCandidates(ScriptUnitId_t nid, GetFuncFlags_t flags, const std::string &funcName, const std::string &fmtFuncDecl)
Finds a function by full declaration, and if not found, finds candidates by name and logs them to Ang...
AngelScript::asIScriptEngine * engine
instance of the scripting engine
AngelScript::asIScriptFunction * eventCallbackFunctionPtr
script function pointer to the event callback function
@ TERRAIN
Defined in terrn2 file under '[Scripts]', receives terrain eventbox notifications.
ScriptUnitId_t m_terrain_script_unit
const std::string GETFUNC_DEFAULTEVENTCALLBACK_SIGFMT
ActorPtr associatedActor
For ScriptCategory::ACTOR.
Proxy class that can be called by script functions.
int fireEvent(std::string instanceName, float intensity)
const GetFuncFlags_t GETFUNCFLAG_REQUIRED
Always logs warning that function was not found.
std::map< ScriptUnitId_t, ScriptUnit > ScriptUnitMap
eventsource_t * eventsource
Unified game event system - all requests and state changes are reported using a message.
AngelScript::asIScriptFunction * eventCallbackExFunctionPtr
script function pointer to the event callback function
AngelScript::asIScriptContext * context
context in which all scripting happens
ScriptUnitMap m_script_units
int functionExists(const Ogre::String &arg)
Checks if a global function exists.
@ ACTOR
Defined in truck file under 'scripts', contains global variable BeamClass@ thisActor.
InterThreadStoreVector< Ogre::String > stringExecutionQueue
The string execution queue.
ScriptCategory
Note: Either of these can be loaded from script using game.pushMessage(MSG_APP_LOAD_SCRIPT_REQUESTED....
ScriptCallbackArgs(eventsource_t *evs, NodeNum_t nd)
Ogre::String scriptBuffer
AngelScript::asIScriptModule * scriptModule
scriptEvents
This enum describes what events are existing. The script can register to receive events.
ScriptUnit & getScriptUnit(ScriptUnitId_t unique_id)
@ CUSTOM
Loaded by user via either: A) ingame console 'loadscript'; B) RoR.cfg 'app_custom_scripts'; C) comman...
int deleteFunction(const Ogre::String &arg)
Deletes a global function from the script.
int addFunction(const Ogre::String &arg)
Adds a global function to the script.
@ MSG_SIM_SCRIPT_EVENT_TRIGGERED
Payload = RoR::ScriptEventArgs* (owner)
const GetFuncFlags_t GETFUNCFLAG_SILENT
Never logs.
void messageLogged(const Ogre::String &message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool &skipThisMessage)