mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-08 11:30:21 +01:00
fix crash if not player
This commit is contained in:
parent
399ece08b6
commit
e447b010ce
|
@ -95,39 +95,41 @@ local function tick()
|
||||||
minetest.after(1, tick)
|
minetest.after(1, tick)
|
||||||
for playername,hudids in pairs(inventory_icon.hudids) do
|
for playername,hudids in pairs(inventory_icon.hudids) do
|
||||||
local player = minetest.get_player_by_name(playername)
|
local player = minetest.get_player_by_name(playername)
|
||||||
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "main")
|
if player then
|
||||||
local icon, color
|
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "main")
|
||||||
if occupied >= size then
|
local icon, color
|
||||||
icon = "inventory_icon_backpack_full.png"
|
if occupied >= size then
|
||||||
else
|
icon = "inventory_icon_backpack_full.png"
|
||||||
icon = "inventory_icon_backpack_free.png"
|
else
|
||||||
end
|
icon = "inventory_icon_backpack_free.png"
|
||||||
player:hud_change(hudids.main.icon, "text", icon)
|
end
|
||||||
player:hud_change(hudids.main.text, "text", string.format("%d/%d", occupied, size))
|
player:hud_change(hudids.main.icon, "text", icon)
|
||||||
|
player:hud_change(hudids.main.text, "text", string.format("%d/%d", occupied, size))
|
||||||
|
|
||||||
if minetest.get_modpath("unified_inventory") ~= nil then
|
if minetest.get_modpath("unified_inventory") ~= nil then
|
||||||
local bags_inv = minetest.get_inventory({type = "detached", name = playername.."_bags"})
|
local bags_inv = minetest.get_inventory({type = "detached", name = playername.."_bags"})
|
||||||
for i=1,4 do
|
for i=1,4 do
|
||||||
local bag = bags_inv:get_stack("bag"..i, 1)
|
local bag = bags_inv:get_stack("bag"..i, 1)
|
||||||
local scale, text, icon
|
local scale, text, icon
|
||||||
if bag:is_empty() then
|
if bag:is_empty() then
|
||||||
scale = { x = 0, y = 0 }
|
scale = { x = 0, y = 0 }
|
||||||
text = ""
|
text = ""
|
||||||
icon = "inventory_icon_bags_small.png"
|
icon = "inventory_icon_bags_small.png"
|
||||||
else
|
else
|
||||||
scale = { x = 1, y = 1 }
|
scale = { x = 1, y = 1 }
|
||||||
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
|
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
|
||||||
text = string.format("%d/%d", occupied, size)
|
text = string.format("%d/%d", occupied, size)
|
||||||
icon = inventory_icon.replace_icon(minetest.registered_items[bag:get_name()].inventory_image)
|
icon = inventory_icon.replace_icon(minetest.registered_items[bag:get_name()].inventory_image)
|
||||||
if occupied >= size then
|
if occupied >= size then
|
||||||
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
|
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
player:hud_change(inventory_icon.hudids[playername].bags[i].icon, "text", icon)
|
||||||
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].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, "text", text)
|
||||||
player:hud_change(inventory_icon.hudids[playername].bags[i].text, "scale", scale)
|
player:hud_change(inventory_icon.hudids[playername].bags[i].text, "scale", scale)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user