From 3362334ee12b3a1c1fbe6827678b01c77d1d8f46 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sat, 18 Jun 2016 09:35:57 +0100 Subject: [PATCH] Show health stats on punch --- api.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/api.lua b/api.lua index 80d53fc..e6e954c 100644 --- a/api.lua +++ b/api.lua @@ -1,5 +1,5 @@ --- Mobs Api (17th June 2016) +-- Mobs Api (18th June 2016) mobs = {} mobs.mod = "redo" @@ -307,6 +307,14 @@ function check_for_death(self) self.health = self.hp_max end + -- backup nametag so we can show health stats + if not self.nametag2 then + self.nametag2 = self.nametag or "" + self.htimer = 5 + end + + self.nametag = "health: " .. self.health .. " of " .. self.hp_max + update_tag(self) return false @@ -420,6 +428,12 @@ do_env_damage = function(self) self.htimer = self.htimer - 1 end + -- reset nametag after showing health stats + if self.htimer < 1 and self.nametag2 then + self.nametag = self.nametag2 + update_tag(self) + end + local pos = self.object:getpos() self.time_of_day = minetest.get_timeofday()