Corrige un crash si le joueur possédait un sac de couleurs

This commit is contained in:
sys4-fr 2019-02-15 19:56:17 +01:00
parent 23dcd3ba6c
commit 53ac160342

View File

@ -26,7 +26,15 @@ function inventory_icon.get_inventory_state(inv, listname)
end
function inventory_icon.replace_icon(name)
return name.."^[resize:32x32"
local item = ""
if name:find("small") then
item = "unified_inventory:bag_small"
elseif name:find("medium") then
item = "unified_inventory:bag_medium"
elseif name:find("large") then
item = "unified_inventory:bag_large"
end
return minetest.registered_items[item].inventory_image.."^[resize:32x32"
end
minetest.register_on_joinplayer(function(player)
@ -71,7 +79,7 @@ minetest.register_on_joinplayer(function(player)
scale = { x = 1, y = 1 }
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
text = S("@1/@2", occupied, size)
icon = inventory_icon.replace_icon(minetest.registered_items[bag:get_name()].inventory_image)
icon = inventory_icon.replace_icon(bag:get_name())
if occupied >= size then
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
end
@ -133,7 +141,7 @@ minetest.register_globalstep(function(dtime)
scale = { x = 1, y = 1 }
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
text = S("@1/@2", occupied, size)
icon = inventory_icon.replace_icon(minetest.registered_items[bag:get_name()].inventory_image)
icon = inventory_icon.replace_icon(bag:get_name())
if occupied >= size then
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
end