From 358250012f477810a2ff072b8e70467c89464935 Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 9 Nov 2022 19:53:50 +0100 Subject: [PATCH] Remove banner when not attached --- mods/ENVIRONMENT/mcl_raids/init.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_raids/init.lua b/mods/ENVIRONMENT/mcl_raids/init.lua index ec6527b49..1a9005bf8 100644 --- a/mods/ENVIRONMENT/mcl_raids/init.lua +++ b/mods/ENVIRONMENT/mcl_raids/init.lua @@ -73,10 +73,12 @@ local oban_layers = { local oban_def = table.copy(minetest.registered_entities["mcl_banners:standing_banner"]) oban_def.visual_size = { x=1, y=1 } -oban_def.on_rightclick = function(self) - minetest.log(dump(self._base_color)) - minetest.log(dump(self._layers)) +local old_step = oban_def.on_step +oban_def.on_step = function(self,dtime) + if not self.object:get_attach() then return self.object:remove() end + if old_step then return old_step(self.dtime) end end + minetest.register_entity(":mcl_raids:ominous_banner",oban_def) function mcl_raids.drop_obanner(pos) @@ -93,11 +95,6 @@ function mcl_raids.promote_to_raidcaptain(c) -- object l._banner = minetest.add_entity(pos,"mcl_raids:ominous_banner") l._banner:set_properties({textures = {mcl_banners.make_banner_texture("unicolor_white", oban_layers)}}) l._banner:set_attach(c,"",vector.new(-1,5.5,0),vector.new(0,0,0),true) - local bl = l._banner:get_luaentity() - bl.parent = c - bl.on_step = function(self,dtime) - if not self.parent or not self.parent:get_pos() then return self.object:remove() end - end l._raidcaptain = true local old_ondie = l.on_die l.on_die = function(self, pos, cmi_cause)