Add support for old bags mod
This commit is contained in:
parent
1750111664
commit
7bc1afbeb0
@ -1 +1,2 @@
|
|||||||
|
bags?
|
||||||
unified_inventory?
|
unified_inventory?
|
||||||
|
7
init.lua
7
init.lua
@ -3,6 +3,9 @@ inventory_icon.hudids = {}
|
|||||||
|
|
||||||
inventory_icon.COLORIZE_STRING = "[colorize:#A00000:192"
|
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)
|
function inventory_icon.get_inventory_state(inv, listname)
|
||||||
local size = inv:get_size(listname)
|
local size = inv:get_size(listname)
|
||||||
local occupied = 0
|
local occupied = 0
|
||||||
@ -46,7 +49,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
text = string.format("%d/%d", occupied, size)
|
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 = {}
|
inventory_icon.hudids[name].bags = {}
|
||||||
local bags_inv = minetest.get_inventory({type = "detached", name = name.."_bags"})
|
local bags_inv = minetest.get_inventory({type = "detached", name = name.."_bags"})
|
||||||
for i=1,4 do
|
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.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
|
if mod_ui or mod_bags 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)
|
||||||
|
Loading…
Reference in New Issue
Block a user