Add support for old bags mod

This commit is contained in:
Wuzzy 2016-09-01 20:16:24 +02:00
parent 1750111664
commit 7bc1afbeb0
2 changed files with 6 additions and 2 deletions

@ -1 +1,2 @@
bags?
unified_inventory?

@ -3,6 +3,9 @@ inventory_icon.hudids = {}
inventory_icon.COLORIZE_STRING = "[colorize:#A00000:192"
local mod_ui = minetest.get_modpath("unified_inventory") ~= nil
local mod_bags = minetest.get_modpath("bags") ~= nil
function inventory_icon.get_inventory_state(inv, listname)
local size = inv:get_size(listname)
local occupied = 0
@ -46,7 +49,7 @@ minetest.register_on_joinplayer(function(player)
number = 0xFFFFFF,
text = string.format("%d/%d", occupied, size)
})
if minetest.get_modpath("unified_inventory") ~= nil then
if mod_ui or mod_bags then
inventory_icon.hudids[name].bags = {}
local bags_inv = minetest.get_inventory({type = "detached", name = name.."_bags"})
for i=1,4 do
@ -107,7 +110,7 @@ minetest.register_globalstep(function(dtime)
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 mod_ui or mod_bags 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)