setmetatable(angle_indices, {__index = function () return 1 end})\r
setmetatable(angle_values, {__index = function () return 90 end})\r
\r
---given multiple sets of privileges, produces a single set of privs that would have the same effect as requiring all of them at the same time\r
+-- given multiple sets of privileges, produces a single set of privs that would have the same effect as requiring all of them at the same time\r
local combine_privs = function(...)\r
local result = {}\r
for i, privs in ipairs({...}) do\r
return result\r
end\r
\r
+-- display node (or unknown_node image otherwise) at specified pos in formspec\r
+local formspec_node = function(pos, nodename)\r
+ return nodename and string.format("item_image[%s;1,1;%s]", pos, nodename)\r
+ or string.format("image[%s;1,1;worldedit_gui_unknown.png]", pos)\r
+end\r
+\r
worldedit.register_gui_function("worldedit_gui_about", {\r
name = "About", privs = minetest.chatcommands["/about"].privs,\r
on_select = function(name)\r
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_set") ..\r
string.format("field[0.5,1.5;4,0.8;worldedit_gui_set_node;Name;%s]", minetest.formspec_escape(node)) ..\r
"button[4,1.18;1.5,0.8;worldedit_gui_set_search;Search]" ..\r
- (nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)\r
- or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,1.1", nodename) ..\r
"button_exit[0,2.5;3,0.8;worldedit_gui_set_submit;Set Nodes]"\r
end,\r
})\r
return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_replace") ..\r
string.format("field[0.5,1.5;4,0.8;worldedit_gui_replace_search;Name;%s]", minetest.formspec_escape(search)) ..\r
"button[4,1.18;1.5,0.8;worldedit_gui_replace_search_search;Search]" ..\r
- (search_nodename and string.format("item_image[5.5,1.1;1,1;%s]", search_nodename)\r
- or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,1.1", search_nodename) ..\r
string.format("field[0.5,2.5;4,0.8;worldedit_gui_replace_replace;Name;%s]", minetest.formspec_escape(replace)) ..\r
"button[4,2.18;1.5,0.8;worldedit_gui_replace_replace_search;Search]" ..\r
- (replace_nodename and string.format("item_image[5.5,2.1;1,1;%s]", replace_nodename)\r
- or "image[5.5,2.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,2.1", replace_nodename) ..\r
"button_exit[0,3.5;3,0.8;worldedit_gui_replace_submit;Replace Nodes]" ..\r
"button_exit[3.5,3.5;3,0.8;worldedit_gui_replace_submit_inverse;Replace Inverse]"\r
end,\r
return "size[6.5,5]" .. worldedit.get_formspec_header("worldedit_gui_sphere_dome") ..\r
string.format("field[0.5,1.5;4,0.8;worldedit_gui_sphere_dome_node;Name;%s]", minetest.formspec_escape(node)) ..\r
"button[4,1.18;1.5,0.8;worldedit_gui_sphere_dome_search;Search]" ..\r
- (nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)\r
- or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,1.1", nodename) ..\r
string.format("field[0.5,2.5;4,0.8;worldedit_gui_sphere_dome_radius;Radius;%s]", minetest.formspec_escape(radius)) ..\r
"button_exit[0,3.5;3,0.8;worldedit_gui_sphere_dome_submit_hollow;Hollow Sphere]" ..\r
"button_exit[3.5,3.5;3,0.8;worldedit_gui_sphere_dome_submit_solid;Solid Sphere]" ..\r
return "size[6.5,5]" .. worldedit.get_formspec_header("worldedit_gui_cylinder") ..\r
string.format("field[0.5,1.5;4,0.8;worldedit_gui_cylinder_node;Name;%s]", minetest.formspec_escape(node)) ..\r
"button[4,1.18;1.5,0.8;worldedit_gui_cylinder_search;Search]" ..\r
- (nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)\r
- or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,1.1", nodename) ..\r
string.format("field[0.5,2.5;4,0.8;worldedit_gui_cylinder_length;Length;%s]", minetest.formspec_escape(length)) ..\r
string.format("dropdown[4,2.18;2.5;worldedit_gui_cylinder_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..\r
string.format("field[0.5,3.5;4,0.8;worldedit_gui_cylinder_radius;Radius;%s]", minetest.formspec_escape(radius)) ..\r
return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_pyramid") ..\r
string.format("field[0.5,1.5;4,0.8;worldedit_gui_pyramid_node;Name;%s]", minetest.formspec_escape(node)) ..\r
"button[4,1.18;1.5,0.8;worldedit_gui_pyramid_search;Search]" ..\r
- (nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)\r
- or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,1.1", nodename) ..\r
string.format("field[0.5,2.5;4,0.8;worldedit_gui_pyramid_length;Length;%s]", minetest.formspec_escape(length)) ..\r
string.format("dropdown[4,2.18;2.5;worldedit_gui_pyramid_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..\r
"button_exit[0,3.5;3,0.8;worldedit_gui_pyramid_submit_hollow;Hollow Pyramid]" ..\r
return "size[6.5,6]" .. worldedit.get_formspec_header("worldedit_gui_spiral") ..\r
string.format("field[0.5,1.5;4,0.8;worldedit_gui_spiral_node;Name;%s]", minetest.formspec_escape(node)) ..\r
"button[4,1.18;1.5,0.8;worldedit_gui_spiral_search;Search]" ..\r
- (nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)\r
- or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,1.1", nodename) ..\r
string.format("field[0.5,2.5;4,0.8;worldedit_gui_spiral_length;Side Length;%s]", minetest.formspec_escape(length)) ..\r
string.format("field[0.5,3.5;4,0.8;worldedit_gui_spiral_height;Height;%s]", minetest.formspec_escape(height)) ..\r
string.format("field[0.5,4.5;4,0.8;worldedit_gui_spiral_space;Wall Spacing;%s]", minetest.formspec_escape(space)) ..\r
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_suppress") ..\r
string.format("field[0.5,1.5;4,0.8;worldedit_gui_suppress_node;Name;%s]", minetest.formspec_escape(node)) ..\r
"button[4,1.18;1.5,0.8;worldedit_gui_suppress_search;Search]" ..\r
- (nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)\r
- or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,1.1", nodename) ..\r
"button_exit[0,2.5;3,0.8;worldedit_gui_suppress_submit;Suppress Nodes]"\r
end,\r
})\r
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_highlight") ..\r
string.format("field[0.5,1.5;4,0.8;worldedit_gui_highlight_node;Name;%s]", minetest.formspec_escape(node)) ..\r
"button[4,1.18;1.5,0.8;worldedit_gui_highlight_search;Search]" ..\r
- (nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)\r
- or "image[5.5,1.1;1,1;unknown_node.png]") ..\r
+ formspec_node("5.5,1.1", nodename) ..\r
"button_exit[0,2.5;3,0.8;worldedit_gui_highlight_submit;Highlight Nodes]"\r
end,\r
})\r