aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-05-11 19:15:23 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-05-11 19:15:23 +0200
commitb7abc8df281390b1fb5def31866086029209aa67 (patch)
tree648a3e1b4922c1912f1503043e613f34a0a32e38 /src/script/cpp_api
parent4f613bbf5118ebe8c3610514e7f4206e930783bf (diff)
downloaddragonfireclient-b7abc8df281390b1fb5def31866086029209aa67.tar.xz
Add on_object_add callback2021.05
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r--src/script/cpp_api/s_client.cpp19
-rw-r--r--src/script/cpp_api/s_client.h1
2 files changed, 18 insertions, 2 deletions
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp
index 7971e4081..5990c4df2 100644
--- a/src/script/cpp_api/s_client.cpp
+++ b/src/script/cpp_api/s_client.cpp
@@ -297,7 +297,7 @@ void ScriptApiClient::on_object_properties_change(s16 id)
{
SCRIPTAPI_PRECHECKHEADER
- // Get core.on_object_properties_change
+ // Get core.registered_on_object_properties_change
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_object_properties_change");
@@ -312,7 +312,7 @@ void ScriptApiClient::on_object_hp_change(s16 id)
{
SCRIPTAPI_PRECHECKHEADER
- // Get core.on_object_hp_change
+ // Get core.registered_on_object_hp_change
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_object_hp_change");
@@ -323,6 +323,21 @@ void ScriptApiClient::on_object_hp_change(s16 id)
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
}
+void ScriptApiClient::on_object_add(s16 id)
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ // Get core.registered_on_object_add
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_object_add");
+
+ // Push data
+ push_objectRef(L, id);
+
+ // Call functions
+ runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
+}
+
bool ScriptApiClient::on_inventory_open(Inventory *inventory)
{
SCRIPTAPI_PRECHECKHEADER
diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h
index a2babfac8..12d96d81e 100644
--- a/src/script/cpp_api/s_client.h
+++ b/src/script/cpp_api/s_client.h
@@ -65,6 +65,7 @@ public:
bool on_spawn_particle(struct ParticleParameters param);
void on_object_properties_change(s16 id);
void on_object_hp_change(s16 id);
+ void on_object_add(s16 id);
bool on_inventory_open(Inventory *inventory);
void open_enderchest();