This commit is contained in:
parent
9d067a0950
commit
0c20e29b34
|
@ -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
|
||||
|
|
2
init.lua
2
init.lua
|
@ -32,6 +32,8 @@ unified_inventory = {
|
|||
pages = {},
|
||||
buttons = {},
|
||||
|
||||
ring_dst = {},
|
||||
|
||||
-- Homepos stuff
|
||||
home_pos = {},
|
||||
home_filename = worldpath.."/unified_inventory_home.home",
|
||||
|
|
|
@ -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
|
||||
|
|
11
register.lua
11
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,
|
||||
|
|
Loading…
Reference in New Issue