mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2024-08-20 21:34:09 +02:00
bags: Add buttons to quickly switch bags in sub-form.
This commit is contained in:
parent
0764000d99
commit
8073df0134
22
bags.lua
22
bags.lua
@ -56,6 +56,28 @@ for i = 1, 4 do
|
|||||||
formspec = (formspec.."background[6.06,0;0.92,0.92;ui_bags_trash.png]"
|
formspec = (formspec.."background[6.06,0;0.92,0.92;ui_bags_trash.png]"
|
||||||
.."list[detached:trash;main;6,0.1;1,1;]")
|
.."list[detached:trash;main;6,0.1;1,1;]")
|
||||||
end
|
end
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
for i = 1, 4 do
|
||||||
|
local def = inv:get_stack("bag"..i, 1):get_definition()
|
||||||
|
local button
|
||||||
|
if def.groups.bagslots then
|
||||||
|
local list_name = "bag"..i.."contents"
|
||||||
|
local size = inv:get_size(list_name)
|
||||||
|
local used = 0
|
||||||
|
for si = 1, size do
|
||||||
|
local stk = inv:get_stack(list_name, si)
|
||||||
|
if not stk:is_empty() then
|
||||||
|
used = used + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local img = def.inventory_image
|
||||||
|
local label = F("Bag @1", i).."\n"..used.."/"..size
|
||||||
|
button = "image_button["..(i+1)..",0;1,1;"..img..";bag"..i..";"..label.."]"
|
||||||
|
else
|
||||||
|
button = ""
|
||||||
|
end
|
||||||
|
formspec = formspec..button
|
||||||
|
end
|
||||||
return {formspec=formspec}
|
return {formspec=formspec}
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user