Add no_prepend[] by default

This commit is contained in:
Emiel van Rooijen 2019-03-31 12:19:08 +02:00 committed by SmallJoker
parent 4d5e883629
commit 16babc54f3
2 changed files with 11 additions and 9 deletions

View File

@ -24,10 +24,12 @@ Register a new page: The callback inside this function is called on user input.
return { return {
formspec = "button[2,2;2,1;mybutton;Press me]", formspec = "button[2,2;2,1;mybutton;Press me]",
-- ^ Final form of the formspec to display -- ^ Final form of the formspec to display
draw_inventory = false, draw_inventory = false, -- default `true`
-- ^ Optional. Hides the player's `main` inventory list -- ^ Optional. Hides the player's `main` inventory list
draw_item_list = false, draw_item_list = false, -- default `true`
-- ^ Optional. Hides the item list on the right side -- ^ Optional. Hides the item list on the right side
formspec_prepend = false, -- default `false`
-- ^ Optional. When `false`: Disables the formspec prepend
} }
end, end,
}) })

View File

@ -58,15 +58,20 @@ function unified_inventory.get_formspec(player, page)
unified_inventory.current_page[player_name] = page unified_inventory.current_page[player_name] = page
local pagedef = unified_inventory.pages[page] local pagedef = unified_inventory.pages[page]
if not pagedef then
return "" -- Invalid page name
end
local formspec = { local formspec = {
"size[14,10]", "size[14,10]",
pagedef.formspec_prepend and "" or "no_prepend[]",
"background[-0.19,-0.25;14.4,10.75;ui_form_bg.png]" -- Background "background[-0.19,-0.25;14.4,10.75;ui_form_bg.png]" -- Background
} }
local n = 3 local n = 4
if draw_lite_mode then if draw_lite_mode then
formspec[1] = "size[11,7.7]" formspec[1] = "size[11,7.7]"
formspec[2] = "background[-0.19,-0.2;11.4,8.4;ui_form_bg.png]" formspec[3] = "background[-0.19,-0.2;11.4,8.4;ui_form_bg.png]"
end end
if unified_inventory.is_creative(player_name) if unified_inventory.is_creative(player_name)
@ -75,11 +80,6 @@ function unified_inventory.get_formspec(player, page)
n = n+1 n = n+1
end end
-- Current page
if not unified_inventory.pages[page] then
return "" -- Invalid page name
end
local perplayer_formspec = unified_inventory.get_per_player_formspec(player_name) local perplayer_formspec = unified_inventory.get_per_player_formspec(player_name)
local fsdata = pagedef.get_formspec(player, perplayer_formspec) local fsdata = pagedef.get_formspec(player, perplayer_formspec)