forked from mtcontrib/mobs_redo
Show health stats on punch
This commit is contained in:
parent
d1bee49785
commit
3362334ee1
16
api.lua
16
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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user