Optimize some formspecs triggering
This commit is contained in:
parent
c35ed36b53
commit
2dc1d7f429
@ -3,13 +3,18 @@ local enchanting = {}
|
|||||||
function enchanting.construct(pos)
|
function enchanting.construct(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
||||||
meta:set_string("formspec", "size[8,7;]"..xbg..
|
local concat = table.concat
|
||||||
|
|
||||||
|
local f = {"size[8,7;]"..xbg..
|
||||||
"label[0.85,-0.15;Enchant]".."image[0.6,0.2;2,2;xdecor_enchbook.png]"..
|
"label[0.85,-0.15;Enchant]".."image[0.6,0.2;2,2;xdecor_enchbook.png]"..
|
||||||
"list[current_name;tool;0.5,2;1,1;]"..
|
"list[current_name;tool;0.5,2;1,1;]"..
|
||||||
"list[current_name;mese;1.5,2;1,1;]".."image[1.5,2;1,1;mese_layout.png]"..
|
"list[current_name;mese;1.5,2;1,1;]".."image[1.5,2;1,1;mese_layout.png]"..
|
||||||
"image_button[2.75,0;5,1.5;ench_bg.png;durable;Durable]"..
|
"image_button[2.75,0;5,1.5;ench_bg.png;durable;Durable]"..
|
||||||
"image_button[2.75,1.5;5,1.5;ench_bg.png;fast;Fast]"..
|
"image_button[2.75,1.5;5,1.5;ench_bg.png;fast;Fast]"..
|
||||||
"list[current_player;main;0,3.3;8,4;]")
|
"list[current_player;main;0,3.3;8,4;]"}
|
||||||
|
local formspec = concat(f)
|
||||||
|
|
||||||
|
meta:set_string("formspec", formspec)
|
||||||
meta:set_string("infotext", "Enchantment Table")
|
meta:set_string("infotext", "Enchantment Table")
|
||||||
|
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
8
hive.lua
8
hive.lua
@ -3,14 +3,18 @@ local hive = {}
|
|||||||
function hive.construct(pos)
|
function hive.construct(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
||||||
|
local concat = table.concat
|
||||||
|
|
||||||
meta:set_string("formspec", "size[8,5;]"..xbg..
|
local f = {"size[8,5;]"..xbg..
|
||||||
"label[1.35,0;Bees are making honey\nwith pollen around...]"..
|
"label[1.35,0;Bees are making honey\nwith pollen around...]"..
|
||||||
"image[0.2,-0.1;1,1;flowers_dandelion_white.png]"..
|
"image[0.2,-0.1;1,1;flowers_dandelion_white.png]"..
|
||||||
"image[7,0.1;1,1;flowers_viola.png]"..
|
"image[7,0.1;1,1;flowers_viola.png]"..
|
||||||
"image[6,0;1,1;xdecor_bee.png]"..
|
"image[6,0;1,1;xdecor_bee.png]"..
|
||||||
"list[current_name;honey;5,0;1,1;]"..
|
"list[current_name;honey;5,0;1,1;]"..
|
||||||
"list[current_player;main;0,1.35;8,4;]")
|
"list[current_player;main;0,1.35;8,4;]"}
|
||||||
|
local formspec = concat(f)
|
||||||
|
|
||||||
|
meta:set_string("formspec", formspec)
|
||||||
meta:set_string("infotext", "Artificial Hive")
|
meta:set_string("infotext", "Artificial Hive")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("honey", 1)
|
inv:set_size("honey", 1)
|
||||||
|
21
mailbox.lua
21
mailbox.lua
@ -1,4 +1,6 @@
|
|||||||
local mailbox = {}
|
local mailbox = {}
|
||||||
|
local concat = table.concat
|
||||||
|
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
||||||
|
|
||||||
xdecor.register("mailbox", {
|
xdecor.register("mailbox", {
|
||||||
description = "Mailbox",
|
description = "Mailbox",
|
||||||
@ -25,9 +27,8 @@ xdecor.register("mailbox", {
|
|||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
|
|
||||||
if owner == player then
|
if owner == player then
|
||||||
minetest.show_formspec(player, "default:chest_locked",
|
minetest.show_formspec(player, "", mailbox.get_formspec(pos))
|
||||||
mailbox.get_formspec(pos))
|
else minetest.show_formspec(player, "",
|
||||||
else minetest.show_formspec(player, "default:chest_locked",
|
|
||||||
mailbox.get_insert_formspec(pos, owner))
|
mailbox.get_insert_formspec(pos, owner))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -59,24 +60,22 @@ xdecor.register("mailbox", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
|
||||||
|
|
||||||
function mailbox.get_formspec(pos)
|
function mailbox.get_formspec(pos)
|
||||||
local spos = pos.x..","..pos.y..","..pos.z
|
local spos = pos.x..","..pos.y..","..pos.z
|
||||||
local formspec =
|
local f = {"size[8,9]"..xbg..
|
||||||
"size[8,9]"..xbg..
|
|
||||||
"label[0,0;You received...]"..
|
"label[0,0;You received...]"..
|
||||||
"list[nodemeta:"..spos..";main;0,0.75;8,4;]"..
|
"list[nodemeta:"..spos..";main;0,0.75;8,4;]"..
|
||||||
"list[current_player;main;0,5.25;8,4;]"
|
"list[current_player;main;0,5.25;8,4;]"}
|
||||||
|
local formspec = concat(f)
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
function mailbox.get_insert_formspec(pos, owner)
|
function mailbox.get_insert_formspec(pos, owner)
|
||||||
local spos = pos.x..","..pos.y..","..pos.z
|
local spos = pos.x..","..pos.y..","..pos.z
|
||||||
local formspec =
|
local f = {"size[8,5]"..xbg..
|
||||||
"size[8,5]"..xbg..
|
|
||||||
"label[0.5,0;Send your goods\nto "..owner.." :]"..
|
"label[0.5,0;Send your goods\nto "..owner.." :]"..
|
||||||
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
|
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
|
||||||
"list[current_player;main;0,1.25;8,4;]"
|
"list[current_player;main;0,1.25;8,4;]"}
|
||||||
|
local formspec = concat(f)
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
@ -4,8 +4,8 @@ local concat = table.concat
|
|||||||
|
|
||||||
local material = {
|
local material = {
|
||||||
"cloud", -- Only used for the formspec display.
|
"cloud", -- Only used for the formspec display.
|
||||||
"wood", "junglewood", "pinewood", "acacia_wood",
|
"wood", "junglewood", "pine_wood", "acacia_wood",
|
||||||
"tree", "jungletree", "pinetree", "acacia_tree",
|
"tree", "jungletree", "pine_tree", "acacia_tree",
|
||||||
"cobble", "mossycobble", "desert_cobble",
|
"cobble", "mossycobble", "desert_cobble",
|
||||||
"stone", "sandstone", "desert_stone", "obsidian",
|
"stone", "sandstone", "desert_stone", "obsidian",
|
||||||
"stonebrick", "sandstonebrick", "desert_stonebrick", "obsidianbrick",
|
"stonebrick", "sandstonebrick", "desert_stonebrick", "obsidianbrick",
|
||||||
@ -98,6 +98,7 @@ function worktable.construct(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function worktable.fields(pos, _, fields, sender)
|
function worktable.fields(pos, _, fields, sender)
|
||||||
|
local player = sender:get_player_name()
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local inputstack = inv:get_stack("input", 1)
|
local inputstack = inv:get_stack("input", 1)
|
||||||
@ -120,13 +121,11 @@ function worktable.fields(pos, _, fields, sender)
|
|||||||
inv:set_stack("input", 1, inputstack)
|
inv:set_stack("input", 1, inputstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if fields["storage"] then
|
if fields.storage then
|
||||||
local player = sender:get_player_name()
|
minetest.show_formspec(player, "", worktable.storage(pos))
|
||||||
minetest.show_formspec(player, "xdecor:worktable", worktable.storage(pos))
|
|
||||||
end
|
end
|
||||||
if fields["craft"] then
|
if fields.craft then
|
||||||
local player = sender:get_player_name()
|
minetest.show_formspec(player, "", worktable.crafting(pos))
|
||||||
minetest.show_formspec(player, "xdecor:worktable", worktable.crafting(pos))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user