Fix timeer, revert text color to white

This commit is contained in:
Wuzzy 2015-05-27 18:25:09 +02:00
parent c3cd4e8589
commit 2f4c3c85fc

View File

@ -18,13 +18,11 @@ minetest.register_on_joinplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()
inventory_icon.hudids[name] = {} inventory_icon.hudids[name] = {}
local occupied, size = inventory_icon.get_inventory_state(player) local occupied, size = inventory_icon.get_inventory_state(player)
local icon, color local icon
if occupied >= size then if occupied >= size then
icon = "inventory_icon_backpack_full.png" icon = "inventory_icon_backpack_full.png"
color = "0xFF0000"
else else
icon = "inventory_icon_backpack_free.png" icon = "inventory_icon_backpack_free.png"
color = "0xFFFFFF"
end end
inventory_icon.hudids[name].icon = player:hud_add({ inventory_icon.hudids[name].icon = player:hud_add({
hud_elem_type = "image", hud_elem_type = "image",
@ -39,7 +37,7 @@ minetest.register_on_joinplayer(function(player)
scale = {x=1,y=1}, scale = {x=1,y=1},
offset = {x=-36,y=-20}, offset = {x=-36,y=-20},
alignment = {x=0,y=0}, alignment = {x=0,y=0},
number = color, number = 0xFFFFFF,
text = string.format("%d/%d", occupied, size) text = string.format("%d/%d", occupied, size)
}) })
end) end)
@ -58,14 +56,12 @@ minetest.register_globalstep(function(dtime)
local icon, color local icon, color
if occupied >= size then if occupied >= size then
icon = "inventory_icon_backpack_full.png" icon = "inventory_icon_backpack_full.png"
color = "0xFF0000"
else else
icon = "inventory_icon_backpack_free.png" icon = "inventory_icon_backpack_free.png"
color = "0xFFFFFF"
end end
player:hud_change(hudids.icon, "text", icon) player:hud_change(hudids.icon, "text", icon)
player:hud_change(hudids.text, "text", string.format("%d/%d", occupied, size)) player:hud_change(hudids.text, "text", string.format("%d/%d", occupied, size))
player:hud_change(hudids.text, "number", color)
end end
inventory_icon.timer = 0
end end
end) end)