summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-06-18 09:35:57 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2016-06-18 09:35:57 +0100
commit3362334ee12b3a1c1fbe6827678b01c77d1d8f46 (patch)
tree15a7a18e88e9f50b83f828fb93629f49eff8f36f
parentd1bee49785453aaaed95b1fbe0c31225de5cb9ce (diff)
Show health stats on punch
-rw-r--r--api.lua16
1 files changed, 15 insertions, 1 deletions
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()