From 6948b7722690aedb680b092989a507a9731dacb3 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 11 Nov 2022 19:20:43 +0100 Subject: [PATCH] move debug/nametag code back to api.lua --- mods/ENTITIES/mcl_mobs/api.lua | 24 ++++++++++++++++++++++++ mods/ENTITIES/mcl_mobs/physics.lua | 23 ----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 679436def..dd75b8e3d 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -55,6 +55,30 @@ local node_ok = function(pos, fallback) return minetest.registered_nodes[fallback] end +function mob_class:update_tag() --update nametag and/or the debug box + local tag + if mobs_debug then + tag = "nametag = '"..tostring(self.nametag).."'\n".. + "state = '"..tostring(self.state).."'\n".. + "order = '"..tostring(self.order).."'\n".. + "attack = "..tostring(self.attack).."\n".. + "health = "..tostring(self.health).."\n".. + "breath = "..tostring(self.breath).."\n".. + "gotten = "..tostring(self.gotten).."\n".. + "tamed = "..tostring(self.tamed).."\n".. + "horny = "..tostring(self.horny).."\n".. + "hornytimer = "..tostring(self.hornytimer).."\n".. + "runaway_timer = "..tostring(self.runaway_timer).."\n".. + "following = "..tostring(self.following).."\n".. + "lifetimer = "..tostring(self.lifetimer) + else + tag = self.nametag + end + self.object:set_properties({ + nametag = tag, + }) +end + function mob_class:get_staticdata() for _,p in pairs(minetest.get_connected_players()) do diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index bbeffd710..c3bc7fbc6 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -250,29 +250,6 @@ function mob_class:update_roll() end -function mob_class:update_tag() - local tag - if mobs_debug then - tag = "nametag = '"..tostring(self.nametag).."'\n".. - "state = '"..tostring(self.state).."'\n".. - "order = '"..tostring(self.order).."'\n".. - "attack = "..tostring(self.attack).."\n".. - "health = "..tostring(self.health).."\n".. - "breath = "..tostring(self.breath).."\n".. - "gotten = "..tostring(self.gotten).."\n".. - "tamed = "..tostring(self.tamed).."\n".. - "horny = "..tostring(self.horny).."\n".. - "hornytimer = "..tostring(self.hornytimer).."\n".. - "runaway_timer = "..tostring(self.runaway_timer).."\n".. - "following = "..tostring(self.following) - else - tag = self.nametag - end - self.object:set_properties({ - nametag = tag, - }) -end - local function shortest_term_of_yaw_rotation(self, rot_origin, rot_target, nums) if not rot_origin or not rot_target then