Created
May 20, 2015 13:28
-
-
Save Amaz1/e98c2e5810ce4c05f307 to your computer and use it in GitHub Desktop.
nametag_healthbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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