Skip to content

Instantly share code, notes, and snippets.

@Amaz1
Created May 20, 2015 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Amaz1/e98c2e5810ce4c05f307 to your computer and use it in GitHub Desktop.
Save Amaz1/e98c2e5810ce4c05f307 to your computer and use it in GitHub Desktop.
nametag_healthbar
--nametag_healthbar, made by Amaz.
--This sets the player's nametag to a colour depending on his/her health.
--License: WTFPL
local count = 0
minetest.register_globalstep(function(dtime)
count = count + dtime
if count > 5 then
count = 0
local players = minetest.get_connected_players()
for _,player in pairs(players) do
local hp = player:get_hp()
if hp >= 15 then
player:set_nametag_attributes({
color = {r = 0, g = 255, b = 0}
})
elseif hp >= 6 then
player:set_nametag_attributes({
color = {r = 255, g = 165, b = 0}
})
elseif hp < 6 then
player:set_nametag_attributes({
color = {r = 255, g = 0, b = 0}
})
end
end
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment