Version MFF.
0
README.txt
Normal file → Executable file
2
depends.txt
Normal file → Executable file
@ -1 +1 @@
|
||||
unified_inventory?
|
||||
unified_inventory
|
||||
|
0
description.txt
Normal file → Executable file
26
init.lua
Normal file → Executable file
@ -16,7 +16,15 @@ function inventory_icon.get_inventory_state(inv, listname)
|
||||
end
|
||||
|
||||
function inventory_icon.replace_icon(name)
|
||||
return "inventory_icon_"..name
|
||||
local icon = ""
|
||||
if name:find("small") then
|
||||
icon = "inventory_icon_bags_small.png"
|
||||
elseif name:find("medium") then
|
||||
icon = "inventory_icon_bags_medium.png"
|
||||
elseif name:find("large") then
|
||||
icon = "inventory_icon_bags_large.png"
|
||||
end
|
||||
return icon
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
@ -60,7 +68,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 = string.format("%d/%d", 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
|
||||
@ -91,12 +99,11 @@ minetest.register_on_leaveplayer(function(player)
|
||||
inventory_icon.hudids[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
inventory_icon.timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
inventory_icon.timer = inventory_icon.timer + dtime
|
||||
if inventory_icon.timer > 1 then
|
||||
local function tick()
|
||||
minetest.after(1, tick)
|
||||
for playername,hudids in pairs(inventory_icon.hudids) do
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
if player then
|
||||
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "main")
|
||||
local icon, color
|
||||
if occupied >= size then
|
||||
@ -120,7 +127,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 = string.format("%d/%d", 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,6 +140,7 @@ minetest.register_globalstep(function(dtime)
|
||||
end
|
||||
end
|
||||
end
|
||||
inventory_icon.timer = 0
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
tick()
|
||||
|
BIN
textures/inventory_icon_backpack_free.png
Normal file → Executable file
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 348 B |
BIN
textures/inventory_icon_backpack_full.png
Normal file → Executable file
Before Width: | Height: | Size: 720 B After Width: | Height: | Size: 345 B |
BIN
textures/inventory_icon_bags_large.png
Normal file → Executable file
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 660 B |
BIN
textures/inventory_icon_bags_medium.png
Normal file → Executable file
Before Width: | Height: | Size: 922 B After Width: | Height: | Size: 836 B |
BIN
textures/inventory_icon_bags_small.png
Normal file → Executable file
Before Width: | Height: | Size: 699 B After Width: | Height: | Size: 625 B |