From 48a85110527c0cff66817092f6f12552a254f2ad Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Fri, 4 Nov 2022 14:28:51 -0600 Subject: [PATCH] Make bossbars enablable/disablable per event type. Update some capitalization. --- mods/CORE/mcl_events/init.lua | 12 +++++++----- mods/ENVIRONMENT/mcl_raids/init.lua | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mods/CORE/mcl_events/init.lua b/mods/CORE/mcl_events/init.lua index aa8a14b0af..7754ea2b91 100644 --- a/mods/CORE/mcl_events/init.lua +++ b/mods/CORE/mcl_events/init.lua @@ -34,22 +34,24 @@ function mcl_events.register_event(name,def) end local function addbars(self) + if not self.enable_bossbar then return end for _,player in pairs(minetest.get_connected_players()) do if vector.distance(self.pos,player:get_pos()) < 75 then - local bar = mcl_bossbars.add_bar(player, {color = "red", text = self.name .. " stage "..self.stage.." / "..self.max_stage, percentage = self.percent }, true,1) + local bar = mcl_bossbars.add_bar(player, {color = "red", text = self.readable_name .. ": Wave "..self.stage.." / "..self.max_stage, percentage = self.percent }, true,1) table.insert(self.bars,bar) end end end local function update_bars(self) + if not self.enable_bossbar then return end for _,b in pairs(self.bars) do - mcl_bossbars.update_bar(b,{text = self.name .. " stage "..self.stage,percentage=self.percent}) + mcl_bossbars.update_bar(b,{text = self.readable_name .. ": Wave "..self.stage,percentage=self.percent}) end end local function start_event(p,e) - mcl_log("event started: "..e.name.." at "..minetest.pos_to_string(vector.round(p.pos))) + mcl_log("[mcl_events] Event started: "..e.readable_name.." at "..minetest.pos_to_string(vector.round(p.pos))) local idx = #active_events + 1 active_events[idx] = table.copy(e) setmetatable(active_events[idx],e) @@ -63,7 +65,7 @@ local function start_event(p,e) end local function finish_event(self,idx) - mcl_log("Finished: "..self.name.." at "..minetest.pos_to_string(vector.round(self.pos))) + mcl_log("[mcl_events] Finished: "..self.readable_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) @@ -113,7 +115,7 @@ function check_events(dtime) if start then start_event(p,e) elseif DBG then - mcl_log("event "..e.name.." already active at "..minetest.pos_to_string(vector.round(p.pos))) + mcl_log("[mcl_events] Event "..e.readable_name.." already active at "..minetest.pos_to_string(vector.round(p.pos))) end end end diff --git a/mods/ENVIRONMENT/mcl_raids/init.lua b/mods/ENVIRONMENT/mcl_raids/init.lua index 1d57034c9e..4b8d81fe94 100644 --- a/mods/ENVIRONMENT/mcl_raids/init.lua +++ b/mods/ENVIRONMENT/mcl_raids/init.lua @@ -111,10 +111,12 @@ function mcl_raids.find_village(pos) end mcl_events.register_event("raid",{ + readable_name = "Raid", max_stage = 5, health = 1, health_max = 1, exclusive_to_area = 128, + enable_bossbar = true, cond_start = function(self) local r = {} for _,p in pairs(minetest.get_connected_players()) do