From 627ce0dc3bc72ebea2d31e4d348e0194107e017a Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 23 Oct 2022 00:13:28 +0200 Subject: [PATCH] Finish at max_stage not max_stage + 1 --- mods/CORE/mcl_events/init.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mods/CORE/mcl_events/init.lua b/mods/CORE/mcl_events/init.lua index 164dfdaa1c..8c440e22c8 100644 --- a/mods/CORE/mcl_events/init.lua +++ b/mods/CORE/mcl_events/init.lua @@ -44,10 +44,12 @@ local etime = 0 function check_events(dtime) for idx,ae in pairs(active_events) do if ae.cond_complete and ae:cond_complete() then + ae.finished = true finish_event(ae,idx) - elseif ae.max_stage and ae.max_stage < ae.stage then + elseif not ae.cond_complete and ae.max_stage and ae.max_stage <= ae.stage then + ae.finished = true finish_event(ae,idx) - elseif ae.cond_progress then + elseif not ae.finished and ae.cond_progress then local p = ae:cond_progress() if p == true then ae.stage = ae.stage + 1 @@ -58,8 +60,7 @@ function check_events(dtime) minetest.log("event progressed to stage "..ae.stage) ae:on_stage_begin() end - - elseif ae.on_step then + elseif not ae.finished and ae.on_step then ae:on_step() end end @@ -92,7 +93,6 @@ mcl_events.register_event("infestation",{ end, on_start = function(self) self.mobs = {} - minetest.log("inf") end, cond_progress = function(self) local m = {} @@ -113,6 +113,9 @@ mcl_events.register_event("infestation",{ end end end, + cond_complete = function(self) + return self.stage >= self.max_stage + end, on_complete = function(self) minetest.log("INFESTATION complete") end,