mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-25 02:00:21 +01:00
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 = {}
|
||||||
mobs.mod = "redo"
|
mobs.mod = "redo"
|
||||||
@ -307,6 +307,14 @@ function check_for_death(self)
|
|||||||
self.health = self.hp_max
|
self.health = self.hp_max
|
||||||
end
|
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)
|
update_tag(self)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@ -420,6 +428,12 @@ do_env_damage = function(self)
|
|||||||
self.htimer = self.htimer - 1
|
self.htimer = self.htimer - 1
|
||||||
end
|
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()
|
local pos = self.object:getpos()
|
||||||
|
|
||||||
self.time_of_day = minetest.get_timeofday()
|
self.time_of_day = minetest.get_timeofday()
|
||||||
|
Loading…
Reference in New Issue
Block a user