diff options
author | cora <coradelamouche@gmx.ch> | 2023-09-03 01:12:42 +0200 |
---|---|---|
committer | cora <coradelamouche@gmx.ch> | 2023-09-03 01:12:42 +0200 |
commit | e2d01755b923048350359b20e31bcab2d9ddada0 (patch) | |
tree | 9554f734280111fc8bbe6675cd2a629252ae67df | |
parent | 6df1590803bf89eca455238aae006a74c98b8ce2 (diff) | |
download | dragonfireclient-e2d01755b923048350359b20e31bcab2d9ddada0.tar.xz |
Add on_receive_particlespawner lua CSM callback
-rw-r--r-- | builtin/client/register.lua | 1 | ||||
-rw-r--r-- | src/network/clientpackethandler.cpp | 2 | ||||
-rw-r--r-- | src/script/cpp_api/s_client.cpp | 42 | ||||
-rw-r--r-- | src/script/cpp_api/s_client.h | 1 |
4 files changed, 45 insertions, 1 deletions
diff --git a/builtin/client/register.lua b/builtin/client/register.lua index 637a22556..6629a4cb2 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -104,6 +104,7 @@ core.registered_on_inventory_open, core.register_on_inventory_open = make_regist core.registered_on_recieve_physics_override, core.register_on_recieve_physics_override = make_registration() core.registered_on_play_sound, core.register_on_play_sound = make_registration() core.registered_on_spawn_particle, core.register_on_spawn_particle = make_registration() +core.registered_on_receive_particlespawner, core.register_on_receive_particlespawner = make_registration() core.registered_on_object_properties_change, core.register_on_object_properties_change = make_registration() core.registered_on_object_hp_change, core.register_on_object_hp_change = make_registration() core.registered_on_object_add, core.register_on_object_add = make_registration() diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 1f17470af..eceedb643 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1056,7 +1056,7 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt) event->add_particlespawner.p = new ParticleSpawnerParameters(p); event->add_particlespawner.attached_id = attached_id; event->add_particlespawner.id = server_id; - + if (m_mods_loaded && m_script->on_receive_particlespawner(*event->add_particlespawner.p)) return; m_client_event_queue.push(event); } diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp index e54a1361d..9ddf24530 100644 --- a/src/script/cpp_api/s_client.cpp +++ b/src/script/cpp_api/s_client.cpp @@ -346,6 +346,48 @@ bool ScriptApiClient::on_spawn_particle(struct ParticleParameters param) return readParam<bool>(L, -1); } +bool ScriptApiClient::on_receive_particlespawner(struct ParticleSpawnerParameters param) +{ + SCRIPTAPI_PRECHECKHEADER + + lua_getglobal(L, "core"); + lua_getfield(L, -1, "registered_on_receive_particlespawner"); + + // Push data + lua_newtable(L); + setstringfield(L, -1, "texture", param.texture); + lua_pushinteger(L, param.amount); + lua_setfield(L, -2, "amount"); + push_v3f(L, param.minpos); + lua_setfield(L, -2, "minpos"); + push_v3f(L, param.maxpos); + lua_setfield(L, -2, "maxpos"); + push_v3f(L, param.minvel); + lua_setfield(L, -2, "minvel"); + push_v3f(L, param.maxvel); + lua_setfield(L, -2, "maxvel"); + push_v3f(L, param.minacc); + lua_setfield(L, -2, "minacc"); + push_v3f(L, param.maxacc); + lua_setfield(L, -2, "maxacc"); + lua_pushnumber(L, param.time); + lua_setfield(L, -2, "time"); + lua_pushnumber(L, param.minexptime); + lua_setfield(L, -2, "minexptime"); + lua_pushnumber(L, param.maxexptime); + lua_setfield(L, -2, "maxexptime"); + lua_pushnumber(L, param.minsize); + lua_setfield(L, -2, "minsize"); + lua_pushnumber(L, param.maxsize); + lua_setfield(L, -2, "maxsize"); + lua_pushinteger(L, param.collisiondetection); + lua_setfield(L, -2, "collisiondetection"); + + // Call functions + runCallbacks(1, RUN_CALLBACKS_MODE_OR); + return readParam<bool>(L, -1); +} + void ScriptApiClient::on_object_properties_change(s16 id) { SCRIPTAPI_PRECHECKHEADER diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h index 6d1a05943..c32a83105 100644 --- a/src/script/cpp_api/s_client.h +++ b/src/script/cpp_api/s_client.h @@ -63,6 +63,7 @@ public: bool new_move); bool on_play_sound(SimpleSoundSpec spec); bool on_spawn_particle(struct ParticleParameters param); + bool on_receive_particlespawner(struct ParticleSpawnerParameters param); void on_object_properties_change(s16 id); void on_object_hp_change(s16 id); bool on_object_add(s16 id); |