From 6de1cd22789e0c06812b5db00fb4095ed390d3ef Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sun, 9 Feb 2025 10:09:32 -0500 Subject: [PATCH] fix some explosion logic from last commits --- docs/hooks.md | 3 ++- quant.ew/files/system/explosion_cuts/explosion_cuts.lua | 8 +++++++- quant.ew/files/system/telekenisis/telekenisis.lua | 2 +- quant.ew/init.lua | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/hooks.md b/docs/hooks.md index 91b6b757..0d42af77 100644 --- a/docs/hooks.md +++ b/docs/hooks.md @@ -1,6 +1,7 @@ # List of available hooks: - `ctx.hook.on_world_initialized()` - called on OnWorldInitialized. + - `ctx.hook.on_new_entity(ent)` - called on new alive entity. - `ctx.hook.on_world_update()` - called on OnWorldPreUpdate. - `ctx.hook.on_world_update_client()` - called on OnWorldPreUpdate, but only on clients. - `ctx.hook.on_world_update_host()` - called on OnWorldPreUpdate, but only on host. @@ -11,4 +12,4 @@ - `ctx.hook.on_draw_debug_window(imgui)` - `ctx.hook.on_local_player_polymorphed(currently_polymorphed)` - `ctx.hook.on_client_polymorphed(peer_id, player_data)` - - `ctx.hook.on_late_init()` - called on OnModPostInit. + - `ctx.hook.on_late_init()` - called on OnModPostInit. \ No newline at end of file diff --git a/quant.ew/files/system/explosion_cuts/explosion_cuts.lua b/quant.ew/files/system/explosion_cuts/explosion_cuts.lua index 3fc80488..2338e7d8 100644 --- a/quant.ew/files/system/explosion_cuts/explosion_cuts.lua +++ b/quant.ew/files/system/explosion_cuts/explosion_cuts.lua @@ -166,9 +166,11 @@ end local exists +local new_ents = {} + function mod.on_new_entity(ent) if ctx.is_host then - update(ent, 1) + table.insert(new_ents, ent) end end @@ -226,6 +228,10 @@ function mod.on_world_pre_update() count2 = count2 - update(ent, count2) end end + for _, ent in ipairs(new_ents) do + update(ent, 1) + end + new_ents = {} if exists then net.proxy_send("flush_exp", "") exists = nil diff --git a/quant.ew/files/system/telekenisis/telekenisis.lua b/quant.ew/files/system/telekenisis/telekenisis.lua index 2e21f87f..2ee0815a 100644 --- a/quant.ew/files/system/telekenisis/telekenisis.lua +++ b/quant.ew/files/system/telekenisis/telekenisis.lua @@ -146,4 +146,4 @@ function tele.on_world_update() end end -return tele \ No newline at end of file +return tele diff --git a/quant.ew/init.lua b/quant.ew/init.lua index c6e2f196..107f1145 100755 --- a/quant.ew/init.lua +++ b/quant.ew/init.lua @@ -677,4 +677,4 @@ end function OnPlayerDied(player_entity) ctx.hook.on_player_died(player_entity) print("player died") -end \ No newline at end of file +end