From 608da950e46d28cc76cf1faa7766868b80c58538 Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 9 Nov 2022 00:56:42 +0100 Subject: [PATCH] Abort events when no player is near --- mods/CORE/mcl_events/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mods/CORE/mcl_events/init.lua b/mods/CORE/mcl_events/init.lua index 7754ea2b91..a0b764163d 100644 --- a/mods/CORE/mcl_events/init.lua +++ b/mods/CORE/mcl_events/init.lua @@ -120,6 +120,18 @@ function check_events(dtime) end end end + for idx,ae in pairs(active_events) do + local player_near = false + for _,pl in pairs(minetest.get_connected_players()) do + if ae.pos and vector.distance(pl:get_pos(),ae.pos) < 256 then player_near = true end + end + if ae.pos and not player_near then + if ae.fail and ae:fail() ~= true then + mcl_log("[mcl_events] Event "..e.readable_name.." at "..minetest.pos_to_string(vector.round(p.pos)).." aborted - no players near." ) + active_events[idx] = nil + end + end + end end minetest.register_globalstep(check_events)