Browse Source

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

master nalc-1.0
sys4-fr 3 years ago
parent
commit
53ac160342
  1. 14
      init.lua

14
init.lua

@ -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

Loading…
Cancel
Save