items/mcl_crafting_table: upgrade to formspec v3

The crafting table formspec can now support overlaying items over top of
the craft prediction slot, including banners.
This commit is contained in:
E 2021-05-03 04:51:26 -04:00
parent 842cc6d1e4
commit 7f938b985e
1 changed files with 12 additions and 13 deletions

View File

@ -3,7 +3,7 @@ local formspec_escape = minetest.formspec_escape
local show_formspec = minetest.show_formspec
local C = minetest.colorize
local text_color = "#313131"
local itemslot_bg = mcl_formspec.get_itemslot_bg
local itemslot_bg, size2r, xy2r = mcl_formspec.get_itemslot_bgv2, mcl_formspec.size2r, mcl_formspec.xy2r
mcl_crafting_table = {
last_table={}
@ -13,25 +13,24 @@ function mcl_crafting_table.show_crafting_form(player, overlay)
player:get_inventory():set_size("craft", 9)
show_formspec(player:get_player_name(), "mcl_crafting_table:main",
"size[9,8.75]"..
"image[4.7,1.5;1.5,1;gui_crafting_arrow.png]"..
"label[0,4;"..formspec_escape(C(text_color, S("Inventory"))).."]".. --"#313131"
"list[current_player;main;0,4.5;9,3;9]"..
"formspec_version[3]"..
"size["..size2r(9,8.75).."]"..
"image["..xy2r(4.7,1.5)..";1.5,1;gui_crafting_arrow.png]"..
"label["..xy2r(0,4)..";"..formspec_escape(C(text_color, S("Inventory"))).."]".. --"#313131"
itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
"list[current_player;main;"..xy2r(0,4.5)..";9,3;9]"..
itemslot_bg(0,7.74,9,1)..
"label[1.75,0;"..formspec_escape(C(text_color, S("Crafting"))).."]"..
"list[current_player;craft;1.75,0.5;3,3;]"..
"list[current_player;main;"..xy2r(0,7.74)..";9,1;]"..
"label["..xy2r(1.75,0)..";"..formspec_escape(C(text_color, S("Crafting"))).."]"..
itemslot_bg(1.75,0.5,3,3)..
"list[current_player;craftpreview;6.1,1.5;1,1;]"..
"list[current_player;craft;"..xy2r(1.75,0.5)..";3,3;]"..
itemslot_bg(6.1,1.5,1,1)..
"image_button[0.75,1.5;1,1;craftguide_book.png;__mcl_craftguide;]"..
"list[current_player;craftpreview;"..xy2r(6.1,1.5)..";1,1;]"..
"image_button["..xy2r(0.75,1.5)..";1,1;craftguide_book.png;__mcl_craftguide;]"..
"tooltip[__mcl_craftguide;"..formspec_escape(S("Recipe book")).."]"..
"listring[current_player;main]"..
"listring[current_player;craft]"..
(overlay and "image[7.1,1.5;1,1;"..formspec_escape(overlay).."]" or "")
-- The overlay can be scooted back over top of the craftpreview once this formspec is
-- updated to version 3.
(overlay and "image["..xy2r(6.1,1.5)..";1,1;"..formspec_escape(overlay).."]" or "")
)
end