29#include "scriptstdstring/scriptstdstring.h"
30#include "scriptmath/scriptmath.h"
31#include "scriptany/scriptany.h"
32#include "scriptarray/scriptarray.h"
33#include "scripthelper/scripthelper.h"
55#include "ScriptEvents.h"
64using namespace AngelScript;
70 case ScriptCategory::INVALID:
return "INVALID";
71 case ScriptCategory::ACTOR:
return "ACTOR";
72 case ScriptCategory::TERRAIN:
return "TERRAIN";
73 case ScriptCategory::CUSTOM:
return "CUSTOM";
121 SLOG(
"ScriptEngine initializing ...");
125 engine = AngelScript::asCreateScriptEngine(ANGELSCRIPT_VERSION);
127 engine->SetEngineProperty(AngelScript::asEP_ALLOW_UNSAFE_REFERENCES,
true);
136 if (result == AngelScript::asINVALID_ARG)
138 SLOG(
"One of the arguments is incorrect, e.g. obj is null for a class method.");
141 else if (result == AngelScript::asNOT_SUPPORTED)
143 SLOG(
" The arguments are not supported, e.g. asCALL_GENERIC.");
146 SLOG(
"Unkown error while setting up message callback");
154 AngelScript::RegisterScriptArray(
engine,
true);
155 AngelScript::RegisterStdString(
engine);
156 AngelScript::RegisterStdStringUtils(
engine);
157 AngelScript::RegisterScriptMath(
engine);
158 static float SCRIPT_FLT_MAX = FLT_MAX;
159 static int SCRIPT_INT_MAX = INT_MAX;
160 result =
engine->RegisterGlobalProperty(
"const float FLT_MAX", &SCRIPT_FLT_MAX);
ROR_ASSERT( result >= 0 );
161 result =
engine->RegisterGlobalProperty(
"const int INT_MAX", &SCRIPT_INT_MAX);
ROR_ASSERT(result >= 0);
162 AngelScript::RegisterScriptAny(
engine);
163 AngelScript::RegisterScriptDictionary(
engine);
166 result =
engine->RegisterGlobalFunction(
"void log(const string &in)", AngelScript::asFUNCTION(
logString), AngelScript::asCALL_CDECL);
ROR_ASSERT( result >= 0 );
167 result =
engine->RegisterGlobalFunction(
"void print(const string &in)", AngelScript::asFUNCTION(
logString), AngelScript::asCALL_CDECL);
ROR_ASSERT( result >= 0 );
198 SLOG(
"Type registrations done. If you see no error above everything should be working");
205 const char *type =
"Error";
206 if ( msg->type == AngelScript::asMSGTYPE_INFORMATION )
208 else if ( msg->type == AngelScript::asMSGTYPE_WARNING )
212 sprintf(tmp,
"%s (%d, %d): %s = %s", msg->section, msg->row, msg->col, type, msg->message);
217 msg->section, msg->message);
220std::string
ptr2str(
const char* ptr) {
if (ptr)
return ptr;
else return ""; }
224 std::string funcName, funcObjTypeName, objName;
225 if (ctx->GetFunction())
227 funcName =
ptr2str(ctx->GetFunction()->GetName());
228 objName =
ptr2str(ctx->GetFunction()->GetObjectName());
229 if (ctx->GetFunction()->GetObjectType())
230 funcObjTypeName =
ptr2str(ctx->GetFunction()->GetObjectType()->GetName());
236 funcName, funcObjTypeName, objName
243 std::string funcName;
244 if (ctx->GetExceptionFunction())
246 funcName =
ptr2str(ctx->GetExceptionFunction()->GetName());
250 funcName, ctx->GetExceptionString());
302 SLOG(fmt::format(
"Warning: Could not attach LineCallback to NID {}, error code {}; continuing without it...", result, nid));
312 SLOG(fmt::format(
"Warning: Could not attach ExceptionCallback to NID {}, error code {}; continuing without it...", result, nid));
318 int result =
context->Execute();
321 if ( result != AngelScript::asEXECUTION_FINISHED )
324 if ( result == AngelScript::asEXECUTION_ABORTED )
326 SLOG(
"The script was aborted before it could finish. Probably it timed out.");
328 else if ( result == AngelScript::asEXECUTION_EXCEPTION )
332 SLOG(
"The script ended with exception; details below:");
336 AngelScript::asIScriptFunction* func =
context->GetExceptionFunction();
339 SLOG(
"\tcontext.ExceptionFunction.Declaration: " +
ptr2str(func->GetDeclaration()));
340 SLOG(
"\tcontext.ExceptionFunction.ModuleName: " +
ptr2str(func->GetModuleName()));
341 SLOG(
"\tcontext.ExceptionFunction.ScriptSectionName: " +
ptr2str(func->GetScriptSectionName()));
342 SLOG(
"\tcontext.ExceptionFunction.ObjectName: " +
ptr2str(func->GetObjectName()));
345 else if (result == AngelScript::asCONTEXT_NOT_PREPARED)
349 SLOG(fmt::format(
"The script ended with error code asCONTEXT_NOT_PREPARED; Function to execute: {},currently triggered event: {}, NID: {}",
354 SLOG(fmt::format(
"The script ended with error code asCONTEXT_NOT_PREPARED; Function to execute NOT SET,currently triggered event: {}, NID: {}",
360 SLOG(
"The script ended for some unforeseen reason " +
TOSTRING(result));
366 context->ClearExceptionCallback();
373 asIScriptFunction* scriptFunc = this->
engine->GetFunctionById(asFunctionID);
376 SLOG(fmt::format(
"Cannot execute script function with ID {} - not found", asFunctionID));
380 int result = this->
context->Prepare(scriptFunc);
383 SLOG(fmt::format(
"Cannot execute script function '{}': `AngelScript::Context::Prepare()` reported error code {}",
384 scriptFunc->GetName(), result));
412 std::vector<String> tmpQueue;
414 std::vector<String>::iterator it;
415 for (it=tmpQueue.begin(); it!=tmpQueue.end();it++)
446 AngelScript::asIScriptFunction* func =
m_script_units[id].scriptModule->GetFunctionByDecl(
447 "void fireEvent(string, float)");
452 context->SetArgObject(0, &instanceName);
453 context->SetArgFloat (1, intensity);
458 if ( r == AngelScript::asEXECUTION_FINISHED )
461 AngelScript::asDWORD ret =
context->GetReturnDWord();
480 int functionId = _functionId;
481 if (functionId <= 0 && (
m_script_units[
id].defaultEventCallbackFunctionPtr !=
nullptr))
484 functionId =
m_script_units[id].defaultEventCallbackFunctionPtr->GetId();
490 context->SetArgDWord (0, type);
494 context->SetArgDWord (3,
static_cast<AngelScript::asDWORD
>(nodenum));
496 context->SetArgDWord (3,
static_cast<AngelScript::asDWORD
>(-1));
511 AngelScript::asIScriptModule* mod =
nullptr;
516 result = ExecuteString(
engine, command.c_str(), mod,
context);
519 SLOG(fmt::format(
"Error {} while executing string `{}`", result, command));
528 AngelScript::asIScriptModule* mod =
nullptr;
532 AngelScript::asIScriptFunction* func =
nullptr;
533 result = mod->CompileFunction(
"addfunc", arg.c_str(), 0, AngelScript::asCOMP_ADD_TO_MODULE, &func);
538 if (func == mod->GetFunctionByDecl(
"void frameStep(float)"))
543 else if (func == mod->GetFunctionByDecl(
"void eventCallback(int, int)"))
548 else if (func == mod->GetFunctionByDecl(
"void eventCallbackEx(scriptEvents, int, int, int, int, string, string, string, string)"))
564 SLOG(fmt::format(
"Error {} adding function `{}` to script module '{}'", result, arg, mod->GetName()));
577 AngelScript::asIScriptModule* mod =
nullptr;
581 if (mod->GetFunctionByDecl(arg.c_str()) !=
nullptr)
590 AngelScript::asIScriptModule* mod =
nullptr;
594 AngelScript::asIScriptFunction* func = mod->GetFunctionByDecl(arg.c_str());
598 result = mod->RemoveFunction(func);
601 SLOG(fmt::format(
"Error {} removing function `{}` from module '{}' - continuing anyway (compatibility).", result, arg, mod->GetName()));
624 SLOG(fmt::format(
"Could not remove function `{}` from module '{}' - not found.", arg, mod->GetName()));
633 AngelScript::asIScriptModule* mod =
nullptr;
637 result = mod->CompileGlobalVar(
"addvar", arg.c_str(), 0);
640 SLOG(fmt::format(
"Error {} while adding variable `{}` to module '{}'", result, arg, mod->GetName()));
649 AngelScript::asIScriptModule* mod =
nullptr;
653 result = mod->GetGlobalVarIndexByName(arg.c_str());
665 AngelScript::asIScriptModule* mod =
nullptr;
669 result = mod->GetGlobalVarIndexByName(arg.c_str());
672 result = mod->RemoveGlobalVar(result);
677 SLOG(fmt::format(
"Error {} while removing variable `{}` from module '{}'", result, arg, mod->GetName()));
684 AngelScript::asIScriptModule* mod =
nullptr;
689 int index = mod->GetGlobalVarIndexByName(varName.c_str());
695 const char* asVarName =
nullptr;
696 const char* asNamespace =
nullptr;
698 bool asConst =
false;
699 int getResult = mod->GetGlobalVar(index, &asVarName, &asNamespace, &asTypeId, &asConst);
705 LOG(fmt::format(
"[RoR|Scripting] getScriptVariable() - '{}' global var info: name='{}', namespace='{}', typeid={}, const={}",
706 varName, asVarName, asNamespace, asTypeId, asConst));
710 if( refTypeId & asTYPEID_OBJHANDLE )
716 if( (asTypeId & asTYPEID_MASK_OBJECT) )
719 if( (asTypeId & asTYPEID_HANDLETOCONST) && !(refTypeId & asTYPEID_HANDLETOCONST) )
721 SLOG(fmt::format(
"Error in `getScriptVariable()` - '{}' is a handle to `const` object but the requested type is not.", varName));
726 engine->RefCastObject(mod->GetAddressOfGlobalVar(index),
engine->GetTypeInfoById(asTypeId),
engine->GetTypeInfoById(refTypeId),
reinterpret_cast<void**
>(ref));
727 if( *(asPWORD*)ref == 0 )
729 SLOG(fmt::format(
"Error in `getScriptVariable()` - '{}': reference-cast from '{}' to '{}' yielded null",
730 varName,
engine->GetTypeDeclaration(asTypeId),
engine->GetTypeDeclaration(refTypeId)));
736 else if( refTypeId & asTYPEID_MASK_OBJECT )
741 if( asTypeId == refTypeId )
743 engine->AssignScriptObject(ref, mod->GetAddressOfGlobalVar(index),
engine->GetTypeInfoById(asTypeId));
752 if( asTypeId == refTypeId )
754 int size =
engine->GetSizeOfPrimitiveType(refTypeId);
755 memcpy(ref, mod->GetAddressOfGlobalVar(index), size);
760 SLOG(fmt::format(
"Error in `getScriptVariable()` - '{}' has incompatible type, expected '{}' (typeid {}), got '{}' (typeid {})",
761 varName,
engine->GetTypeDeclaration(refTypeId), refTypeId,
engine->GetTypeDeclaration(asTypeId), asTypeId));
767 std::string decl = fmt::format(fmtFuncDecl, funcName);
768 asIScriptFunction* retval =
m_script_units[nid].scriptModule->GetFunctionByDecl(decl.c_str());
771 asIScriptFunction* candidate =
m_script_units[nid].scriptModule->GetFunctionByName(funcName.c_str());
774 SLOG(fmt::format(
"Warning: a callback function with signature '{}' was not found"
775 " but a function with given name exists: '{}' - did you make a typo in arguments?",
776 decl, candidate->GetDeclaration()));
780 SLOG(fmt::format(
"Warning: a callback function with signature '{}' was not found",
794 asIScriptFunction* callback =
m_script_units[id].eventCallbackExFunctionPtr;
807 context->SetArgDWord(0, eventnum);
812 context->SetArgDWord(2, arg2ex);
813 context->SetArgDWord(3, arg3ex);
814 context->SetArgDWord(4, arg4ex);
815 context->SetArgObject(5, &arg5ex);
816 context->SetArgObject(6, &arg6ex);
817 context->SetArgObject(7, &arg7ex);
818 context->SetArgObject(8, &arg8ex);
836 ActorPtr associatedActor , std::string buffer )
845 std::string basename, ext, scriptName;
846 Ogre::StringUtil::splitBaseFilename(scriptOrGadgetFileName, basename, ext);
851 if (!originatingGadget)
854 fmt::format(
"Could not load script '{}' - gadget not found.", scriptOrGadgetFileName));
858 scriptName = fmt::format(
"{}.as", basename);
862 else if (ext ==
"as")
864 scriptName = scriptOrGadgetFileName;
869 fmt::format(
"Could not load script '{}' - unknown file extension.", scriptOrGadgetFileName));
938 result = builder.StartNewModule(
engine, moduleName.c_str());
942 fmt::format(
"Could not load script '{}' - failed to create module.", moduleName));
945 m_script_units[unit_id].scriptModule =
engine->GetModule(moduleName.c_str(), AngelScript::asGM_ONLY_IF_EXISTS);
954 fmt::format(
"Could not load script '{}' - failed to create global variable `thisActor`.", moduleName));
961 fmt::format(
"const int thisScript = {};", unit_id).c_str());
965 fmt::format(
"Could not load script '{}' - failed to create global variable `thisScript`.", moduleName));
976 fmt::format(
"Could not load script '{}' from buffer", moduleName));
983 result = builder.AddSectionFromFile(
m_script_units[unit_id].scriptName.c_str());
987 fmt::format(
"Could not load script '{}' - failed to process file.", moduleName));
997 result = builder.BuildModule();
1002 fmt::format(
"Could not load script '{}' - failed to build module. See 'Angelscript.log' for more info.", moduleName));
1008 scriptHash = builder.
GetHash();
1013 m_script_units[unit_id].eventCallbackFunctionPtr =
m_script_units[unit_id].scriptModule->GetFunctionByDecl(
"void eventCallback(int, int)");
1014 m_script_units[unit_id].eventCallbackExFunctionPtr =
m_script_units[unit_id].scriptModule->GetFunctionByDecl(
"void eventCallbackEx(scriptEvents, int, int, int, int, string, string, string, string)");
1021 auto main_func =
m_script_units[unit_id].scriptModule->GetFunctionByDecl(
"void main()");
1022 if ( main_func ==
nullptr )
1033 result =
context->Prepare(main_func);
1037 fmt::format(
"Could not load script '{}' - failed to build module.", moduleName));
1045 int var_index =
m_script_units[unit_id].scriptModule->GetGlobalVarIndexByName(
"thisActor");
1048 SLOG(
"Could not find global var `thisActor`");
1054 if (thisActorAddr ==
nullptr)
1056 SLOG(
"Could not retrieve address of global var `thisActor`");
1059 *thisActorAddr =
m_script_units[unit_id].associatedActor.GetRef();
1060 (*thisActorAddr)->
AddRef();
1065 SLOG(fmt::format(
"Executing main() in {}", moduleName));
1067 if ( mainfunc_result != AngelScript::asEXECUTION_FINISHED )
1070 fmt::format(
"Could not load script '{}' - error running function `main()`, check AngelScript.log", moduleName));
1074 SLOG(
"The script finished successfully.");
1077 return mainfunc_result;
Central state/object manager and communications hub.
#define ROR_ASSERT(_EXPR)
void LOG(const char *msg)
Legacy alias - formerly a macro.
#define BITMASK_IS_1(VAR, FLAGS)
#define BITMASK_IS_0(VAR, FLAGS)
Game state manager and message-queue provider.
std::string ptr2str(const char *ptr)
void logString(const std::string &str)
void pull(std::vector< T > &res)
Softbody object; can be anything from soda can to a space shuttle Constructed from a truck definition...
Ogre::String fname
filename
CacheEntryPtr FindEntryByFilename(RoR::LoaderType type, bool partial, const std::string &_filename_maybe_bundlequalified)
Returns NULL if none found; "Bundle-qualified" format also specifies the ZIP/directory in modcache,...
void LoadResource(CacheEntryPtr &t)
Loads the associated resource bundle if not already done.
@ CONSOLE_MSGTYPE_SCRIPT
Messages sent from scripts.
@ CONSOLE_MSGTYPE_INFO
Generic message.
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
void forwardLogMessage(MessageArea area, std::string const &msg, Ogre::LogMessageLevel lml)
This class represents the angelscript scripting interface.
ScriptUnit & getScriptUnit(ScriptUnitID_t unique_id)
ScriptRetCode_t variableExists(const Ogre::String &arg, const ScriptUnitID_t nid=SCRIPTUNITID_DEFAULT)
Adds a global variable to the script.
ScriptUnitID_t m_terrain_script_unit
void exceptionCallback(AngelScript::asIScriptContext *ctx)
Optional callback invoked when the script critically fails, allowing debugging.
bool m_events_enabled
Hack to enable fast shutdown without cleanup.
ScriptRetCode_t deleteVariable(const Ogre::String &arg, const ScriptUnitID_t nid=SCRIPTUNITID_DEFAULT)
Deletes a global variable from the script.
void forwardExceptionAsScriptEvent(const std::string &from)
Forwards useful info from C++ try{}catch{} exceptions to script in the form of game event.
ScriptRetCode_t addVariable(const Ogre::String &arg, const ScriptUnitID_t nid=SCRIPTUNITID_DEFAULT)
Adds a global variable to the script.
scriptEvents m_currently_executing_event_trigger
ScriptUnitMap m_script_units
int setupScriptUnit(int unit_id)
Helper for loadScript(), does the actual building without worry about unit management.
AngelScript::asIScriptEngine * engine
instance of the scripting engine
ScriptUnitID_t loadScript(Ogre::String filename, ScriptCategory category=ScriptCategory::TERRAIN, ActorPtr associatedActor=nullptr, std::string buffer="")
Loads a script.
bool scriptUnitExists(ScriptUnitID_t unique_id)
int fireEvent(std::string instanceName, float intensity)
ScriptRetCode_t deleteFunction(const Ogre::String &arg, const ScriptUnitID_t nid=SCRIPTUNITID_DEFAULT)
Deletes a global function from the script.
int executeContextAndHandleErrors(ScriptUnitID_t nid)
Helper for executing any script function/snippet; registers Line/Exception callbacks (on demand) and ...
InterThreadStoreVector< Ogre::String > stringExecutionQueue
The string execution queue.
void msgCallback(const AngelScript::asSMessageInfo *msg)
Optional (but very recommended!) callback providing diagnostic info when things fail to start (most n...
void SLOG(const char *msg)
Replacement of macro.
ScriptRetCode_t getVariable(const Ogre::String &varName, void *ref, int typeID, ScriptUnitID_t nid=SCRIPTUNITID_DEFAULT)
Retrieves a global variable from any running script.
ScriptRetCode_t addFunction(const Ogre::String &arg, const ScriptUnitID_t nid=SCRIPTUNITID_DEFAULT)
Adds a global function to the script.
ScriptRetCode_t executeString(Ogre::String command)
executes a string (useful for the console)
ScriptRetCode_t validateScriptModule(const ScriptUnitID_t nid, AngelScript::asIScriptModule *&out_mod)
Helper for all manipulations with functions/variables; ensures the script unit exists and is fully se...
AngelScript::asIScriptContext * context
context in which all scripting happens
void queueStringForExecution(const Ogre::String command)
Queues a string for execution.
void envokeCallback(int functionId, eventsource_t *source, NodeNum_t nodenum=NODENUM_INVALID, int type=0)
void messageLogged(const Ogre::String &message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool &skipThisMessage)
ScriptUnitID_t m_currently_executing_script_unit
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...
void lineCallback(AngelScript::asIScriptContext *ctx)
Optional callback which receives diagnostic info for every executed statement.
Ogre::String composeModuleName(Ogre::String const &scriptName, ScriptCategory origin, ScriptUnitID_t id)
Packs name + important info to one string, for logging and reporting purposes.
ScriptRetCode_t functionExists(const Ogre::String &arg, const ScriptUnitID_t nid=SCRIPTUNITID_DEFAULT)
Checks if a global function exists.
bool prepareContextAndHandleErrors(ScriptUnitID_t nid, int asFunctionID)
Helper for executing any script function/snippet; does asIScriptContext::Prepare() and reports any er...
void setForwardScriptLogToConsole(bool doForward)
void init()
This function initialzies the engine and registeres all types.
void framestep(Ogre::Real dt)
Calls the script's framestep function to be able to use timed things inside the script.
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.
void unloadScript(ScriptUnitID_t unique_id)
Unloads a script.
std::string PathCombine(std::string a, std::string b)
void RegisterGameScript(AngelScript::asIScriptEngine *engine)
Registers RoR::GameScript, defined in GameScriptAngelscript.cpp.
ScriptCategory
Note: Either of these can be loaded from script using game.pushMessage(MSG_APP_LOAD_SCRIPT_REQUESTED....
void RegisterProceduralRoad(AngelScript::asIScriptEngine *engine)
defined in ProceduralRoadAngelscript.cpp
void RegisterLocalStorage(AngelScript::asIScriptEngine *engine)
Registers RoR::LocalStorage, defined in LocalStorageAngelscript.cpp.
void RegisterAutopilot(AngelScript::asIScriptEngine *engine)
void RegisterGenericFileFormat(AngelScript::asIScriptEngine *engine)
defined in GenericFileFormatAngelscript.cpp
void RegisterCacheSystem(AngelScript::asIScriptEngine *engine)
defined in CacheSystemAngelscript.cpp
const std::string GETFUNC_DEFAULTEVENTCALLBACK_NAME
void RegisterOgreObjects(AngelScript::asIScriptEngine *engine)
defined in OgreAngelscript.cpp
BitMask_t GetFuncFlags_t
Flags for RoR::ScriptEngine::getFunctionByDeclAndLogCandidates()
void RegisterConsole(AngelScript::asIScriptEngine *engine)
Registers RoR::Console, defined in ConsoleAngelscript.cpp.
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(),...
void RegisterSoundScript(AngelScript::asIScriptEngine *engine)
defined in SoundScriptAngelscript.cpp
void RegisterDashBoardManager(AngelScript::asIScriptEngine *engine)
const GetFuncFlags_t GETFUNCFLAG_OPTIONAL
Only logs warning if candidate is found, to help modder find a typo.
void RegisterScriptEvents(AngelScript::asIScriptEngine *engine)
Registers enum scriptEvents, defined in ScriptEventsAngelscript.cpp.
const std::string GETFUNC_DEFAULTEVENTCALLBACK_SIGFMT
void RegisterTurbojet(AngelScript::asIScriptEngine *engine)
void RegisterActor(AngelScript::asIScriptEngine *engine)
defined in ActorAngelscript.cpp
const GetFuncFlags_t GETFUNCFLAG_REQUIRED
Always logs warning that function was not found.
const GetFuncFlags_t GETFUNCFLAG_SILENT
Never logs.
void RegisterInputEngine(AngelScript::asIScriptEngine *engine)
Registers RoR::InputEngine, defined in InputEngineAngelscript.cpp.
void RegisterScrewprop(AngelScript::asIScriptEngine *engine)
void RegisterAircraftEngine(AngelScript::asIScriptEngine *engine)
const char * ScriptCategoryToString(ScriptCategory c)
void RegisterTurboprop(AngelScript::asIScriptEngine *engine)
void RegisterEngine(AngelScript::asIScriptEngine *engine)
Register class Engine and related enums, defined in EngineAngelscript.cpp.
void RegisterImGuiBindings(AngelScript::asIScriptEngine *engine)
defined in ImGuiAngelscript.cpp
void RegisterVehicleAi(AngelScript::asIScriptEngine *engine)
defined in VehicleAiAngelscript.cpp
void RegisterTerrain(AngelScript::asIScriptEngine *engine)
Registers RoR::Terrain, defined in TerrainAngelscript.cpp.
void RegisterMessageQueue(AngelScript::asIScriptEngine *engine)
Registers enum MsgType, defined in MsgQueueAngelscript.cpp.
@ CUSTOM
Loaded by user via either: A) ingame console 'loadscript'; B) RoR.cfg 'app_custom_scripts'; C) comman...
@ GADGET
Associated with a .gadget mod file, launched via UI or any method given below for CUSTOM scripts (use...
@ TERRAIN
Defined in terrn2 file under '[Scripts]', receives terrain eventbox notifications.
@ ACTOR
Defined in truck file under 'scripts', contains global variable BeamClass@ thisActor.
@ SCRIPTRETCODE_ENGINE_NOT_CREATED
@ SCRIPTRETCODE_SCRIPTUNIT_NOT_EXISTS
@ SCRIPTRETCODE_UNSPECIFIED_ERROR
@ SCRIPTRETCODE_CONTEXT_NOT_CREATED
@ SCRIPTRETCODE_SCRIPTUNIT_NO_MODULE
@ SCRIPTRETCODE_FUNCTION_NOT_EXISTS
InputEngine * GetInputEngine()
CVar * app_recent_scripts
ScriptEngine * GetScriptEngine()
CacheSystem * GetCacheSystem()
static const NodeNum_t NODENUM_INVALID
@ ASMANIP_SCRIPT_UNLOADING
Triggered before unloading the script to let it clean up. Args: #2 ScriptUnitId_t,...
@ ASMANIP_SCRIPT_LOADED
Triggered after the script's main() completed; Args: #2 ScriptUnitId_t, #3 RoR::ScriptCategory,...
@ ASMANIP_SCRIPT_LOAD_FAILED
Triggered if the script fails to start at all. Args: #2 unused, #3 RoR::ScriptCategory,...
void CvarAddFileToList(CVar *cvar, const std::string &filename)
int ScriptRetCode_t
see enum RoR::ScriptRetCode - combines AngelScript codes and RoR internal codes.
int ScriptUnitID_t
Unique sequentially generated ID of a loaded and running scriptin session. Use ScriptEngine::getScrip...
static const ScriptUnitID_t SCRIPTUNITID_INVALID
scriptEvents
This enum describes what events are existing. The script can register to receive events.
@ SE_ANGELSCRIPT_MANIPULATIONS
triggered when the user tries to dynamically use the scripting capabilities (prevent cheating) args: ...
@ SE_ANGELSCRIPT_MSGCALLBACK
The diagnostic info directly from AngelScript engine (see asSMessageInfo), args: #1 ScriptUnitID,...
@ SE_ANGELSCRIPT_LINECALLBACK
The diagnostic info directly from AngelScript engine (see SetLineCallback()), args: #1 ScriptUnitID,...
@ SE_ANGELSCRIPT_EXCEPTIONCALLBACK
The diagnostic info directly from AngelScript engine (see SetExceptionCallback()),...
@ SE_GENERIC_EXCEPTION_CAUGHT
Triggered when C++ exception (usually Ogre::Exception) is thrown; #1 ScriptUnitID,...
uint16_t NodeNum_t
Node position within Actor::ar_nodes; use RoR::NODENUM_INVALID as empty value.
Represents a loaded script and all associated resources/handles.
AngelScript::asIScriptModule * scriptModule
std::string es_box_name
Specified in ODEF file as "event".
std::string es_instance_name
Specified by user when calling "GameScript::spawnObject()".