summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Martínez <kaeza@users.noreply.github.com>2017-03-22 11:44:18 -0300
committerDiego Martínez <kaeza@users.noreply.github.com>2017-03-24 19:48:59 -0300
commit8073df01346e11011ec9c6c7867415c571a052a6 (patch)
tree6ec7b6eb759dd227cc63aa6dcd90da4e136ffac9
parent0764000d997a91ee491040081fddbf50003d8095 (diff)
bags: Add buttons to quickly switch bags in sub-form.
-rw-r--r--bags.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/bags.lua b/bags.lua
index 3923dab..6d0842f 100644
--- a/bags.lua
+++ b/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]"
.."list[detached:trash;main;6,0.1;1,1;]")
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}
end,
})