]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/script/cpp_api/s_client.cpp
Add on_object_add callback
[dragonfireclient.git] / src / script / cpp_api / s_client.cpp
index 7971e4081891a99587477c3fd7508ac6efc03f0b..5990c4df218289a1883fd12f2d1eb4581aa8f85f 100644 (file)
@@ -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