Add unified_inventory support (part 2)

This commit is contained in:
Wuzzy 2015-06-23 21:35:26 +02:00
parent 9c63d43fef
commit 38c4cde03f

View File

@ -97,6 +97,32 @@ minetest.register_globalstep(function(dtime)
end end
player:hud_change(hudids.main.icon, "text", icon) player:hud_change(hudids.main.icon, "text", icon)
player:hud_change(hudids.main.text, "text", string.format("%d/%d", occupied, size)) player:hud_change(hudids.main.text, "text", string.format("%d/%d", occupied, size))
if minetest.get_modpath("unified_inventory") ~= nil then
local bags_inv = minetest.get_inventory({type = "detached", name = playername.."_bags"})
for i=1,4 do
local bag = bags_inv:get_stack("bag"..i, 1)
local scale, text, icon
if bag:is_empty() then
scale = { x = 0, y = 0 }
text = ""
icon = "bags_small.png"
else
scale = { x = 2, y = 2 }
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
text = string.format("%d/%d", occupied, size)
icon = minetest.registered_items[bag:get_name()].inventory_image
if occupied >= size then
icon = icon .. "^[colorize:#A00000:192"
end
end
player:hud_change(inventory_icon.hudids[playername].bags[i].icon, "text", icon)
player:hud_change(inventory_icon.hudids[playername].bags[i].icon, "scale", scale)
player:hud_change(inventory_icon.hudids[playername].bags[i].text, "text", text)
player:hud_change(inventory_icon.hudids[playername].bags[i].text, "scale", scale)
end
end
end end
inventory_icon.timer = 0 inventory_icon.timer = 0
end end