diff --git a/callbacks.lua b/callbacks.lua index e6ea3e7..e3815bb 100644 --- a/callbacks.lua +++ b/callbacks.lua @@ -168,6 +168,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) unified_inventory.current_page[player_name]) minetest.sound_play("click", {to_player=player_name, gain = 0.1}) + elseif fields.ui_ring_dst then + local possible = {craft = 1, trash = 2, refill = 3} + local invs = {"current_name;craft", "detached:trash;main", "detached:"..minetest.formspec_escape(player_name).."refill;main"} + local ring_dest = possible[fields.ui_ring_dst] or 1 + unified_inventory.ring_dst[player:get_player_name()] = ring_dest + local f = player:get_inventory_formspec() + local bla = f:find("listring[", 1, true) + f = f:sub(1, bla+8)..invs[ring_dest]..f:sub(f:find("]", bla), -1) + bla = f:find(";ui_ring_dst;") + 32 + f = f:sub(1, bla-1)..ring_dest..f:sub(bla+1) + print(f) + player:set_inventory_formspec(f) end -- alternate buttons diff --git a/init.lua b/init.lua index 6929600..5d49daf 100644 --- a/init.lua +++ b/init.lua @@ -32,6 +32,8 @@ unified_inventory = { pages = {}, buttons = {}, + ring_dst = {}, + -- Homepos stuff home_pos = {}, home_filename = worldpath.."/unified_inventory_home.home", @@ -45,7 +47,7 @@ unified_inventory = { -- "Lite" mode lite_mode = minetest.setting_getbool("unified_inventory_lite"), - + -- Trash enabled trash_enabled = (minetest.setting_getbool("unified_inventory_trash") ~= false), diff --git a/internal.lua b/internal.lua index 5732971..2b1ae46 100644 --- a/internal.lua +++ b/internal.lua @@ -29,6 +29,7 @@ function unified_inventory.get_per_player_formspec(player_name) ui.craft_result_x = unified_inventory.craft_result_x ui.craft_result_y = unified_inventory.craft_result_y ui.form_header_y = unified_inventory.form_header_y + ui.ring_dst = unified_inventory.ring_dst[player_name] or 1 if lite then ui.pagecols = 4 @@ -94,7 +95,7 @@ function unified_inventory.get_formspec(player, page) local filtered_inv_buttons = {} for i, def in pairs(unified_inventory.buttons) do - if not (draw_lite_mode and def.hide_lite) then + if not (draw_lite_mode and def.hide_lite) then table.insert(filtered_inv_buttons, def) end end diff --git a/register.lua b/register.lua index c702eab..7f31f45 100644 --- a/register.lua +++ b/register.lua @@ -1,6 +1,8 @@ local S = unified_inventory.gettext local F = unified_inventory.fgettext +local ring_dst = {} + minetest.register_privilege("creative", { description = S("Can use the creative inventory"), give_to_singleplayer = false, @@ -167,6 +169,7 @@ unified_inventory.register_page("craft", { local formspecy = perplayer_formspec.formspec_y local formheadery = perplayer_formspec.form_header_y + local ring_dst = perplayer_formspec.ring_dst local player_name = player:get_player_name() local formspec = "background[2,"..formspecy..";6,3;ui_crafting_form.png]" @@ -180,13 +183,13 @@ unified_inventory.register_page("craft", { formspec = formspec.."background[7,"..(formspecy + 2)..";1,1;ui_single_slot.png]" formspec = formspec.."list[detached:trash;main;7,"..(formspecy + 2)..";1,1;]" end + formspec = formspec.."listring[current_name;craft]" formspec = formspec.."listring[current_player;main]" if unified_inventory.is_creative(player_name) then - formspec = formspec.."listring[detached:trash;main]" + formspec = formspec.."label[0,"..(formspecy)..";Shift-click to:]" + formspec = formspec.."dropdown[0,"..(formspecy + 0.5)..";1;ui_ring_dst;craft,trash,refill;"..ring_dst.."]" formspec = formspec.."label[0,"..(formspecy + 1.5)..";" .. F("Refill:") .. "]" - formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."refill;main;0,"..(formspecy +2)..";1,1;]" - else - formspec = formspec.."listring[current_name;craft]" + formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."refill;main;0,"..(formspecy + 2)..";1,1;]" end return {formspec=formspec} end,