RigsofRods
Soft-body Physics Simulation
ScriptEventsAngelscript.cpp
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-2022 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 
22 #include "ScriptEvents.h"
23 #include "AngelScriptBindings.h"
24 #include "Application.h"
25 #include <angelscript.h>
26 
27 using namespace AngelScript;
28 
29 void RoR::RegisterScriptEvents(asIScriptEngine *engine)
30 {
31  int result;
32 
33  // enum scriptEvents
34  result = engine->RegisterEnum("scriptEvents"); ROR_ASSERT(result>=0);
35 
36  result = engine->RegisterEnumValue("scriptEvents", "SE_EVENTBOX_ENTER", SE_EVENTBOX_ENTER); ROR_ASSERT(result >= 0);
37  result = engine->RegisterEnumValue("scriptEvents", "SE_EVENTBOX_EXIT", SE_EVENTBOX_EXIT); ROR_ASSERT(result >= 0);
38 
39  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_ENTER", SE_TRUCK_ENTER); ROR_ASSERT(result>=0);
40  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_EXIT", SE_TRUCK_EXIT); ROR_ASSERT(result>=0);
41 
42  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_ENGINE_DIED", SE_TRUCK_ENGINE_DIED); ROR_ASSERT(result>=0);
43  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_ENGINE_FIRE", SE_TRUCK_ENGINE_FIRE); ROR_ASSERT(result>=0);
44  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_TOUCHED_WATER", SE_TRUCK_TOUCHED_WATER); ROR_ASSERT(result>=0);
45  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_LIGHT_TOGGLE", SE_TRUCK_LIGHT_TOGGLE); ROR_ASSERT(result>=0);
46  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_TIE_TOGGLE", SE_TRUCK_TIE_TOGGLE); ROR_ASSERT(result>=0);
47  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_PARKINGBRAKE_TOGGLE", SE_TRUCK_PARKINGBRAKE_TOGGLE); ROR_ASSERT(result>=0);
48  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_BEACONS_TOGGLE", SE_TRUCK_BEACONS_TOGGLE); ROR_ASSERT(result>=0);
49  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_CPARTICLES_TOGGLE", SE_TRUCK_CPARTICLES_TOGGLE); ROR_ASSERT(result>=0);
50 
51  result = engine->RegisterEnumValue("scriptEvents", "SE_GENERIC_NEW_TRUCK", SE_GENERIC_NEW_TRUCK); ROR_ASSERT(result>=0);
52  result = engine->RegisterEnumValue("scriptEvents", "SE_GENERIC_DELETED_TRUCK", SE_GENERIC_DELETED_TRUCK); ROR_ASSERT(result>=0);
53 
54  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_RESET", SE_TRUCK_RESET); ROR_ASSERT(result>=0);
55  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_TELEPORT", SE_TRUCK_TELEPORT); ROR_ASSERT(result>=0);
56  result = engine->RegisterEnumValue("scriptEvents", "SE_TRUCK_MOUSE_GRAB", SE_TRUCK_MOUSE_GRAB); ROR_ASSERT(result>=0);
57 
58  result = engine->RegisterEnumValue("scriptEvents", "SE_ANGELSCRIPT_MANIPULATIONS", SE_ANGELSCRIPT_MANIPULATIONS); ROR_ASSERT(result>=0);
59  result = engine->RegisterEnumValue("scriptEvents", "SE_ANGELSCRIPT_MSGCALLBACK", SE_ANGELSCRIPT_MSGCALLBACK); ROR_ASSERT(result>=0);
60  result = engine->RegisterEnumValue("scriptEvents", "SE_ANGELSCRIPT_LINECALLBACK", SE_ANGELSCRIPT_LINECALLBACK); ROR_ASSERT(result>=0);
61  result = engine->RegisterEnumValue("scriptEvents", "SE_ANGELSCRIPT_EXCEPTIONCALLBACK", SE_ANGELSCRIPT_EXCEPTIONCALLBACK); ROR_ASSERT(result>=0);
62  result = engine->RegisterEnumValue("scriptEvents", "SE_ANGELSCRIPT_THREAD_STATUS", SE_ANGELSCRIPT_THREAD_STATUS); ROR_ASSERT(result>=0);
63 
64  result = engine->RegisterEnumValue("scriptEvents", "SE_GENERIC_MESSAGEBOX_CLICK", SE_GENERIC_MESSAGEBOX_CLICK); ROR_ASSERT(result>=0);
65  result = engine->RegisterEnumValue("scriptEvents", "SE_GENERIC_EXCEPTION_CAUGHT", SE_GENERIC_EXCEPTION_CAUGHT); ROR_ASSERT(result>=0);
66  result = engine->RegisterEnumValue("scriptEvents", "SE_GENERIC_MODCACHE_ACTIVITY", SE_GENERIC_MODCACHE_ACTIVITY); ROR_ASSERT(result>=0);
67 
68  result = engine->RegisterEnumValue("scriptEvents", "SE_GENERIC_TRUCK_LINKING_CHANGED", SE_GENERIC_TRUCK_LINKING_CHANGED); ROR_ASSERT(result>=0);
69 
70  result = engine->RegisterEnumValue("scriptEvents", "SE_ALL_EVENTS", SE_ALL_EVENTS); ROR_ASSERT(result>=0);
71  result = engine->RegisterEnumValue("scriptEvents", "SE_NO_EVENTS", SE_NO_EVENTS); ROR_ASSERT(result>=0);
72 
73  // enum angelScriptManipulationType
74  result = engine->RegisterEnum("angelScriptManipulationType"); ROR_ASSERT(result>=0);
75 
76  result = engine->RegisterEnumValue("angelScriptManipulationType", "ASMANIP_CONSOLE_SNIPPET_EXECUTED", ASMANIP_CONSOLE_SNIPPET_EXECUTED); ROR_ASSERT(result >= 0);
77  result = engine->RegisterEnumValue("angelScriptManipulationType", "ASMANIP_SCRIPT_LOADED", ASMANIP_SCRIPT_LOADED); ROR_ASSERT(result >= 0);
78  result = engine->RegisterEnumValue("angelScriptManipulationType", "ASMANIP_SCRIPT_UNLOADING", ASMANIP_SCRIPT_UNLOADING); ROR_ASSERT(result >= 0);
79 
80  // enum angelScriptThreadStatus
81  result = engine->RegisterEnum("angelScriptThreadStatus"); ROR_ASSERT(result>=0);
82 
83  result = engine->RegisterEnumValue("angelScriptThreadStatus", "ASTHREADSTATUS_NONE", ASTHREADSTATUS_NONE); ROR_ASSERT(result >= 0);
84  result = engine->RegisterEnumValue("angelScriptThreadStatus", "ASTHREADSTATUS_CURLSTRING_PROGRESS", ASTHREADSTATUS_CURLSTRING_PROGRESS); ROR_ASSERT(result >= 0);
85  result = engine->RegisterEnumValue("angelScriptThreadStatus", "ASTHREADSTATUS_CURLSTRING_SUCCESS", ASTHREADSTATUS_CURLSTRING_SUCCESS ); ROR_ASSERT(result >= 0);
86  result = engine->RegisterEnumValue("angelScriptThreadStatus", "ASTHREADSTATUS_CURLSTRING_FAILURE", ASTHREADSTATUS_CURLSTRING_FAILURE ); ROR_ASSERT(result >= 0);
87 
88  // enum modCacheActivityType
89  result = engine->RegisterEnum("modCacheActivityType"); ROR_ASSERT(result>=0);
90 
91  result = engine->RegisterEnumValue("modCacheActivityType", "MODCACHEACTIVITY_ENTRY_ADDED", MODCACHEACTIVITY_ENTRY_ADDED); ROR_ASSERT(result >= 0);
92  result = engine->RegisterEnumValue("modCacheActivityType", "MODCACHEACTIVITY_ENTRY_DELETED", MODCACHEACTIVITY_ENTRY_DELETED); ROR_ASSERT(result >= 0);
93  result = engine->RegisterEnumValue("modCacheActivityType", "MODCACHEACTIVITY_BUNDLE_LOADED", MODCACHEACTIVITY_BUNDLE_LOADED); ROR_ASSERT(result >= 0);
94  result = engine->RegisterEnumValue("modCacheActivityType", "MODCACHEACTIVITY_BUNDLE_RELOADED", MODCACHEACTIVITY_BUNDLE_RELOADED); ROR_ASSERT(result >= 0);
95  result = engine->RegisterEnumValue("modCacheActivityType", "MODCACHEACTIVITY_BUNDLE_UNLOADED", MODCACHEACTIVITY_BUNDLE_UNLOADED); ROR_ASSERT(result >= 0);
96 }
ROR_ASSERT
#define ROR_ASSERT(_EXPR)
Definition: Application.h:40
RoR::ASMANIP_SCRIPT_UNLOADING
@ ASMANIP_SCRIPT_UNLOADING
Triggered before unloading the script to let it clean up (important for missions).
Definition: ScriptEvents.h:76
RoR::SE_TRUCK_ENGINE_FIRE
@ SE_TRUCK_ENGINE_FIRE
triggered when the planes engines start to get on fire, the argument refers to the actor ID of the ve...
Definition: ScriptEvents.h:39
RoR::SE_ANGELSCRIPT_MANIPULATIONS
@ SE_ANGELSCRIPT_MANIPULATIONS
triggered when the user tries to dynamically use the scripting capabilities (prevent cheating) args: ...
Definition: ScriptEvents.h:54
RoR::SE_GENERIC_TRUCK_LINKING_CHANGED
@ SE_GENERIC_TRUCK_LINKING_CHANGED
Triggered when 2 actors become linked or unlinked via ties/hooks/ropes/slidenodes; args: #1 state (1=...
Definition: ScriptEvents.h:64
AngelScriptBindings.h
RoR::SE_ANGELSCRIPT_LINECALLBACK
@ SE_ANGELSCRIPT_LINECALLBACK
The diagnostic info directly from AngelScript engine (see SetLineCallback()), args: #1 ScriptUnitID,...
Definition: ScriptEvents.h:56
RoR::SE_GENERIC_MESSAGEBOX_CLICK
@ SE_GENERIC_MESSAGEBOX_CLICK
triggered when the user clicks on a message box button, the argument refers to the button pressed
Definition: ScriptEvents.h:60
RoR::SE_TRUCK_MOUSE_GRAB
@ SE_TRUCK_MOUSE_GRAB
triggered when the user uses the mouse to interact with the actor, the argument refers to the actor I...
Definition: ScriptEvents.h:52
RoR::SE_GENERIC_MODCACHE_ACTIVITY
@ SE_GENERIC_MODCACHE_ACTIVITY
Triggered when status of modcache changes, args: #1 type, #2 entry number, for other args see RoR::mo...
Definition: ScriptEvents.h:62
RoR::SE_GENERIC_NEW_TRUCK
@ SE_GENERIC_NEW_TRUCK
triggered when the user spawns a new actor, the argument refers to the actor ID
Definition: ScriptEvents.h:47
RoR::SE_TRUCK_EXIT
@ SE_TRUCK_EXIT
triggered when switching from vehicle mode to person mode, the argument refers to the actor ID of the...
Definition: ScriptEvents.h:36
RoR::ASTHREADSTATUS_NONE
@ ASTHREADSTATUS_NONE
Definition: ScriptEvents.h:81
RoR::SE_TRUCK_TIE_TOGGLE
@ SE_TRUCK_TIE_TOGGLE
triggered when the user toggles ties, the argument refers to the actor ID
Definition: ScriptEvents.h:42
RoR::SE_TRUCK_ENGINE_DIED
@ SE_TRUCK_ENGINE_DIED
triggered when the vehicle's engine dies (from underrev, water, etc), the argument refers to the acto...
Definition: ScriptEvents.h:38
RoR::SE_EVENTBOX_ENTER
@ SE_EVENTBOX_ENTER
Actor or person entered an eventbox; arguments: #1 type, #2 actorID (actor only), #3 node ID (actor o...
Definition: ScriptEvents.h:32
RoR::ASTHREADSTATUS_CURLSTRING_SUCCESS
@ ASTHREADSTATUS_CURLSTRING_SUCCESS
Args of RoR::SE_ANGELSCRIPT_THREAD_STATUS: arg#1 type, arg#2 HTTP code, arg#3 CURLcode,...
Definition: ScriptEvents.h:83
RoR::ASMANIP_CONSOLE_SNIPPET_EXECUTED
@ ASMANIP_CONSOLE_SNIPPET_EXECUTED
Definition: ScriptEvents.h:74
RoR::MODCACHEACTIVITY_BUNDLE_UNLOADED
@ MODCACHEACTIVITY_BUNDLE_UNLOADED
Args: #1 type, #2 entry number.
Definition: ScriptEvents.h:98
RoR::RegisterScriptEvents
void RegisterScriptEvents(AngelScript::asIScriptEngine *engine)
Registers enum scriptEvents, defined in ScriptEventsAngelscript.cpp.
RoR::SE_TRUCK_PARKINGBRAKE_TOGGLE
@ SE_TRUCK_PARKINGBRAKE_TOGGLE
triggered when the user toggles the parking brake, the argument refers to the actor ID
Definition: ScriptEvents.h:43
RoR::MODCACHEACTIVITY_BUNDLE_RELOADED
@ MODCACHEACTIVITY_BUNDLE_RELOADED
Args: #1 type, #2 entry number, –, –, #5 rg name.
Definition: ScriptEvents.h:97
RoR::MODCACHEACTIVITY_ENTRY_ADDED
@ MODCACHEACTIVITY_ENTRY_ADDED
Args: #1 type, #2 entry number, –, –, #5 fname, #6 fext.
Definition: ScriptEvents.h:92
RoR::SE_TRUCK_ENTER
@ SE_TRUCK_ENTER
triggered when switching from person mode to vehicle mode, the argument refers to the actor ID of the...
Definition: ScriptEvents.h:35
RoR::SE_NO_EVENTS
@ SE_NO_EVENTS
Definition: ScriptEvents.h:67
RoR::SE_GENERIC_EXCEPTION_CAUGHT
@ SE_GENERIC_EXCEPTION_CAUGHT
Triggered when C++ exception (usually Ogre::Exception) is thrown; #1 ScriptUnitID,...
Definition: ScriptEvents.h:61
Application.h
Central state/object manager and communications hub.
RoR::SE_TRUCK_RESET
@ SE_TRUCK_RESET
triggered when the user resets the truck, the argument refers to the actor ID of the vehicle
Definition: ScriptEvents.h:50
RoR::SE_ANGELSCRIPT_MSGCALLBACK
@ SE_ANGELSCRIPT_MSGCALLBACK
The diagnostic info directly from AngelScript engine (see asSMessageInfo), args: #1 ScriptUnitID,...
Definition: ScriptEvents.h:55
RoR::SE_TRUCK_LIGHT_TOGGLE
@ SE_TRUCK_LIGHT_TOGGLE
triggered when the main light is toggled, the argument refers to the actor ID
Definition: ScriptEvents.h:41
RoR::SE_ALL_EVENTS
@ SE_ALL_EVENTS
Definition: ScriptEvents.h:66
RoR::SE_TRUCK_TELEPORT
@ SE_TRUCK_TELEPORT
triggered when the user teleports the truck, the argument refers to the actor ID of the vehicle
Definition: ScriptEvents.h:51
RoR::SE_TRUCK_TOUCHED_WATER
@ SE_TRUCK_TOUCHED_WATER
triggered when any part of the actor touches water, the argument refers to the actor ID
Definition: ScriptEvents.h:40
ScriptEvents.h
RoR::SE_TRUCK_BEACONS_TOGGLE
@ SE_TRUCK_BEACONS_TOGGLE
triggered when the user toggles beacons, the argument refers to the actor ID
Definition: ScriptEvents.h:44
RoR::SE_EVENTBOX_EXIT
@ SE_EVENTBOX_EXIT
Actor or person left an eventbox; arguments: #1 type, #2 actorID (actor only), #3 unused,...
Definition: ScriptEvents.h:33
RoR::ASMANIP_SCRIPT_LOADED
@ ASMANIP_SCRIPT_LOADED
Triggered after the script's main() completed; may trigger additional processing (for example,...
Definition: ScriptEvents.h:75
RoR::MODCACHEACTIVITY_ENTRY_DELETED
@ MODCACHEACTIVITY_ENTRY_DELETED
Flagged as deleted, managed by shared pointers; Args: #1 type, #2 entry number, –,...
Definition: ScriptEvents.h:94
RoR::ASTHREADSTATUS_CURLSTRING_PROGRESS
@ ASTHREADSTATUS_CURLSTRING_PROGRESS
Args of RoR::SE_ANGELSCRIPT_THREAD_STATUS: arg#1 type, arg#2 percentage, arg#3 unused,...
Definition: ScriptEvents.h:82
RoR::MODCACHEACTIVITY_BUNDLE_LOADED
@ MODCACHEACTIVITY_BUNDLE_LOADED
Args: #1 type, #2 entry number, –, –, #5 rg name.
Definition: ScriptEvents.h:96
RoR::SE_ANGELSCRIPT_EXCEPTIONCALLBACK
@ SE_ANGELSCRIPT_EXCEPTIONCALLBACK
The diagnostic info directly from AngelScript engine (see SetExceptionCallback()),...
Definition: ScriptEvents.h:57
RoR::SE_GENERIC_DELETED_TRUCK
@ SE_GENERIC_DELETED_TRUCK
triggered when the user deletes an actor, the argument refers to the actor ID
Definition: ScriptEvents.h:48
RoR::SE_ANGELSCRIPT_THREAD_STATUS
@ SE_ANGELSCRIPT_THREAD_STATUS
Sent by background threads (i.e. CURL) when there's something important (like finishing a download)....
Definition: ScriptEvents.h:58
RoR::ASTHREADSTATUS_CURLSTRING_FAILURE
@ ASTHREADSTATUS_CURLSTRING_FAILURE
Args of RoR::SE_ANGELSCRIPT_THREAD_STATUS: arg#1 type, arg#2 HTTP code, arg#3 CURLcode,...
Definition: ScriptEvents.h:84
RoR::SE_TRUCK_CPARTICLES_TOGGLE
@ SE_TRUCK_CPARTICLES_TOGGLE
triggered when the user toggles custom particles, the argument refers to the actor ID
Definition: ScriptEvents.h:45