Added listring/shift click to bags

This commit is contained in:
DonBatman 2015-10-09 18:55:46 -07:00
parent 5df353c299
commit 9bc6301f60

@ -30,15 +30,80 @@ unified_inventory.register_button("bags", {
hide_lite=true hide_lite=true
}) })
for i = 1, 4 do
unified_inventory.register_page("bag"..i, { unified_inventory.register_page("bag1", {
get_formspec = function(player) get_formspec = function(player)
local stack = player:get_inventory():get_stack("bag"..i, 1) local stack = player:get_inventory():get_stack("bag1", 1)
local image = stack:get_definition().inventory_image local image = stack:get_definition().inventory_image
local formspec = "image[7,0;1,1;"..image.."]" local formspec = "image[7,0;1,1;"..image.."]"
formspec = formspec.."label[0,0;Bag "..i.."]" formspec = formspec.."label[0,0;Bag 1]"
formspec = formspec.."listcolors[#00000000;#00000000]" formspec = formspec.."listcolors[#00000000;#00000000]"
formspec = formspec.."list[current_player;bag"..i.."contents;0,1;8,3;]" formspec = formspec.."list[current_player;bag1contents;0,1;8,3;]"
formspec = formspec.."listring[current_name;bag1contents]"
formspec = formspec.."listring[current_player;main]"
local slots = stack:get_definition().groups.bagslots
if slots == 8 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]"
elseif slots == 16 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]"
elseif slots == 24 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]"
end
return {formspec=formspec}
end,
})
unified_inventory.register_page("bag2", {
get_formspec = function(player)
local stack = player:get_inventory():get_stack("bag2", 1)
local image = stack:get_definition().inventory_image
local formspec = "image[7,0;1,1;"..image.."]"
formspec = formspec.."label[0,0;Bag 2]"
formspec = formspec.."listcolors[#00000000;#00000000]"
formspec = formspec.."list[current_player;bag2contents;0,1;8,3;]"
formspec = formspec.."listring[current_name;bag2contents]"
formspec = formspec.."listring[current_player;main]"
local slots = stack:get_definition().groups.bagslots
if slots == 8 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]"
elseif slots == 16 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]"
elseif slots == 24 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]"
end
return {formspec=formspec}
end,
})
unified_inventory.register_page("bag3", {
get_formspec = function(player)
local stack = player:get_inventory():get_stack("bag3", 1)
local image = stack:get_definition().inventory_image
local formspec = "image[7,0;1,1;"..image.."]"
formspec = formspec.."label[0,0;Bag 3]"
formspec = formspec.."listcolors[#00000000;#00000000]"
formspec = formspec.."list[current_player;bag3contents;0,1;8,3;]"
formspec = formspec.."listring[current_name;bag3contents]"
formspec = formspec.."listring[current_player;main]"
local slots = stack:get_definition().groups.bagslots
if slots == 8 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]"
elseif slots == 16 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]"
elseif slots == 24 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]"
end
return {formspec=formspec}
end,
})
unified_inventory.register_page("bag4", {
get_formspec = function(player)
local stack = player:get_inventory():get_stack("bag4", 1)
local image = stack:get_definition().inventory_image
local formspec = "image[7,0;1,1;"..image.."]"
formspec = formspec.."label[0,0;Bag 4]"
formspec = formspec.."listcolors[#00000000;#00000000]"
formspec = formspec.."list[current_player;bag4contents;0,1;8,3;]"
formspec = formspec.."listring[current_name;bag4contents]"
formspec = formspec.."listring[current_player;main]"
local slots = stack:get_definition().groups.bagslots local slots = stack:get_definition().groups.bagslots
if slots == 8 then if slots == 8 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]"
@ -50,7 +115,6 @@ for i = 1, 4 do
return {formspec=formspec} return {formspec=formspec}
end, end,
}) })
end
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "" then if formname ~= "" then