From 7ab2c5fecd20c1e52a5966b35b994270183a15a1 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 24 Oct 2022 17:37:11 +0200 Subject: [PATCH] Make debug output an opt-in setting --- mods/CORE/mcl_events/init.lua | 14 +++++++++++--- settingtypes.txt | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mods/CORE/mcl_events/init.lua b/mods/CORE/mcl_events/init.lua index 4718dd8df..478b80896 100644 --- a/mods/CORE/mcl_events/init.lua +++ b/mods/CORE/mcl_events/init.lua @@ -1,5 +1,6 @@ mcl_events = {} mcl_events.registered_events = {} +local DBG = minetest.settings:get_bool("mcl_logging_event_api",false) local active_events = {} local tpl_eventdef = { @@ -18,6 +19,13 @@ local tpl_eventdef = { cond_complete = function(event) end, --return success } +local function mcl_log(m,l) + if DBG then + if not l then l = "action" end + minetest.log(l,"[mcl_events] "..m) + end +end + function mcl_events.register_event(name,def) mcl_events.registered_events[name] = {} --setmetatable(mcl_events.registered_events[name],tpl_eventdef) @@ -41,7 +49,7 @@ local function update_bars(self) end local function start_event(p,e) - minetest.log("event started: "..e.name.." at "..minetest.pos_to_string(p)) + mcl_log("event started: "..e.name.." at "..minetest.pos_to_string(vector.round(p))) local idx = #active_events + 1 active_events[idx] = table.copy(e) setmetatable(active_events[idx],e) @@ -55,7 +63,7 @@ local function start_event(p,e) end local function finish_event(self,idx) - minetest.log("event finished: "..self.name.." at "..minetest.pos_to_string(self.pos)) + mcl_log("Finished: "..self.name.." at "..minetest.pos_to_string(vector.round(self.pos))) if self.on_complete then self:on_complete() end for _,b in pairs(self.bars) do mcl_bossbars.remove_bar(b) @@ -159,7 +167,7 @@ mcl_events.register_event("infestation",{ return self.stage >= self.max_stage and #m < 1 end, on_complete = function(self) - minetest.log("INFESTATION complete") + mcl_log("INFESTATION complete") end, }) diff --git a/settingtypes.txt b/settingtypes.txt index 39dbc2e90..1b21316b7 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -233,4 +233,7 @@ mcl_logging_mapgen (Chunk generation logging) bool false mcl_logging_structures (Structure generation logging) bool true #Complete debug logging for mcl_signs events. Use this if you have issues with signs. -mcl_logging_mcl_signs (Complete debug logging for mcl_signs) bool true +mcl_logging_mcl_signs (Complete debug logging for mcl_signs) bool false + +#Debug logging for mcl_events. +mcl_logging_event_api (Debug logging for mcl_events) bool false