summaryrefslogtreecommitdiff
path: root/worldedit_gui/functionality.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-09-26 00:11:57 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-09-26 00:11:57 -0400
commit3d08b568ad1da1e3259a66cb91fd1039781c75cb (patch)
tree59c396f503f3946b8757093f5c90605fe9f91d07 /worldedit_gui/functionality.lua
parent4aab7d0dbd782cf6741bdbba94440faf0c5c2e61 (diff)
downloaddreambuilder_modpack-3d08b568ad1da1e3259a66cb91fd1039781c75cb.tar
dreambuilder_modpack-3d08b568ad1da1e3259a66cb91fd1039781c75cb.tar.gz
dreambuilder_modpack-3d08b568ad1da1e3259a66cb91fd1039781c75cb.tar.bz2
dreambuilder_modpack-3d08b568ad1da1e3259a66cb91fd1039781c75cb.tar.xz
dreambuilder_modpack-3d08b568ad1da1e3259a66cb91fd1039781c75cb.zip
update castles modpack, boost_cart, homedecor, currency, farming redo,
framed glass, gloopblocks, mesecons, moreblocks, pipeworks, signs_lib, technic, unified mesecons, and worldedit created a new tag for this release (this will be standard procedure from now on)
Diffstat (limited to 'worldedit_gui/functionality.lua')
-rw-r--r--worldedit_gui/functionality.lua82
1 files changed, 52 insertions, 30 deletions
diff --git a/worldedit_gui/functionality.lua b/worldedit_gui/functionality.lua
index 17a8a79..912fd59 100644
--- a/worldedit_gui/functionality.lua
+++ b/worldedit_gui/functionality.lua
@@ -1,6 +1,6 @@
--saved state for each player
-local gui_nodename1 = {} --mapping of player names to node names (arbitrary strings may also appear as values)
-local gui_nodename2 = {} --mapping of player names to node names (arbitrary strings may also appear as values)
+local gui_nodename1 = {} --mapping of player names to node names
+local gui_nodename2 = {} --mapping of player names to node names
local gui_axis1 = {} --mapping of player names to axes (one of 1, 2, 3, or 4, representing the axes in the `axis_indices` table below)
local gui_axis2 = {} --mapping of player names to axes (one of 1, 2, 3, or 4, representing the axes in the `axis_indices` table below)
local gui_distance1 = {} --mapping of player names to a distance (arbitrary strings may also appear as values)
@@ -10,9 +10,7 @@ local gui_count1 = {} --mapping of player names to a quantity (arbitrary strings
local gui_count2 = {} --mapping of player names to a quantity (arbitrary strings may also appear as values)
local gui_count3 = {} --mapping of player names to a quantity (arbitrary strings may also appear as values)
local gui_angle = {} --mapping of player names to an angle (one of 90, 180, 270, representing the angle in degrees clockwise)
-local gui_filename = {} --mapping of player names to file names (arbitrary strings may also appear as values)
-local gui_formspec = {} --mapping of player names to formspecs
-local gui_code = {} --mapping of player names to formspecs
+local gui_filename = {} --mapping of player names to file names
--set default values
setmetatable(gui_nodename1, {__index = function() return "Cobblestone" end})
@@ -27,8 +25,6 @@ setmetatable(gui_count2, {__index = function() return "6" end})
setmetatable(gui_count3, {__index = function() return "4" end})
setmetatable(gui_angle, {__index = function() return 90 end})
setmetatable(gui_filename, {__index = function() return "building" end})
-setmetatable(gui_formspec, {__index = function() return "size[5,5]\nlabel[0,0;Hello, world!]" end})
-setmetatable(gui_code, {__index = function() return "minetest.chat_send_player(\"singleplayer\", \"Hello, world!\")" end})
local axis_indices = {["X axis"]=1, ["Y axis"]=2, ["Z axis"]=3, ["Look direction"]=4}
local axis_values = {"x", "y", "z", "?"}
@@ -292,17 +288,21 @@ worldedit.register_gui_function("worldedit_gui_cylinder", {
name = "Cylinder",
privs = combine_we_privs({"hollowcylinder", "cylinder"}),
get_formspec = function(name)
- local node, axis, length, radius = gui_nodename1[name], gui_axis1[name], gui_distance1[name], gui_distance2[name]
+ local node, axis, length = gui_nodename1[name], gui_axis1[name], gui_distance1[name]
+ local radius1, radius2 = gui_distance2[name], gui_distance3[name]
local nodename = worldedit.normalize_nodename(node)
- return "size[6.5,5]" .. worldedit.get_formspec_header("worldedit_gui_cylinder") ..
+ return "size[6.5,6]" .. worldedit.get_formspec_header("worldedit_gui_cylinder") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_cylinder_node;Name;%s]", minetest.formspec_escape(node)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_cylinder_search;Search]" ..
formspec_node("5.5,1.1", nodename) ..
string.format("field[0.5,2.5;4,0.8;worldedit_gui_cylinder_length;Length;%s]", minetest.formspec_escape(length)) ..
string.format("dropdown[4,2.18;2.5;worldedit_gui_cylinder_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
- string.format("field[0.5,3.5;4,0.8;worldedit_gui_cylinder_radius;Radius;%s]", minetest.formspec_escape(radius)) ..
- "button_exit[0,4.5;3,0.8;worldedit_gui_cylinder_submit_hollow;Hollow Cylinder]" ..
- "button_exit[3.5,4.5;3,0.8;worldedit_gui_cylinder_submit_solid;Solid Cylinder]"
+ string.format("field[0.5,3.5;2,0.8;worldedit_gui_cylinder_radius1;Base Radius;%s]", minetest.formspec_escape(radius1)) ..
+ string.format("field[2.5,3.5;2,0.8;worldedit_gui_cylinder_radius2;Top Radius;%s]", minetest.formspec_escape(radius2)) ..
+ "label[0.25,4;Equal base and top radius creates a cylinder,\n"..
+ "zero top radius creates a cone.\nConsult documentation for more information.]"..
+ "button_exit[0,5.5;3,0.8;worldedit_gui_cylinder_submit_hollow;Hollow Cylinder]" ..
+ "button_exit[3.5,5.5;3,0.8;worldedit_gui_cylinder_submit_solid;Solid Cylinder]"
end,
})
@@ -312,7 +312,8 @@ worldedit.register_gui_handler("worldedit_gui_cylinder", function(name, fields)
gui_nodename1[name] = tostring(fields.worldedit_gui_cylinder_node)
gui_axis1[name] = axis_indices[fields.worldedit_gui_cylinder_axis]
gui_distance1[name] = tostring(fields.worldedit_gui_cylinder_length)
- gui_distance2[name] = tostring(fields.worldedit_gui_cylinder_radius)
+ gui_distance2[name] = tostring(fields.worldedit_gui_cylinder_radius1)
+ gui_distance3[name] = tostring(fields.worldedit_gui_cylinder_radius2)
worldedit.show_page(name, "worldedit_gui_cylinder")
local submit = nil
@@ -324,7 +325,8 @@ worldedit.register_gui_handler("worldedit_gui_cylinder", function(name, fields)
if submit then
local n = worldedit.normalize_nodename(gui_nodename1[name])
if n then
- minetest.chatcommands["/"..submit].func(name, string.format("%s %s %s %s", axis_values[gui_axis1[name]], gui_distance1[name], gui_distance2[name], n))
+ local args = string.format("%s %s %s %s %s", axis_values[gui_axis1[name]], gui_distance1[name], gui_distance2[name], gui_distance3[name], n)
+ minetest.chatcommands["/"..submit].func(name, args)
end
end
return true
@@ -733,26 +735,46 @@ worldedit.register_gui_handler("worldedit_gui_save_load", function(name, fields)
return false
end)
-worldedit.register_gui_function("worldedit_gui_lua", {
- name = "Run Lua",
- privs = we_privs("lua"),
+worldedit.register_gui_function("worldedit_gui_cube", {
+ name = "Cuboid", -- technically the command is misnamed, I know...
+ privs = combine_we_privs({"hollowcube", "cube"}),
get_formspec = function(name)
- local code = gui_code[name]
- return "size[8,6.5]" .. worldedit.get_formspec_header("worldedit_gui_lua") ..
- string.format("textarea[0.5,1;7.5,5.5;worldedit_gui_lua_code;Lua Code;%s]", minetest.formspec_escape(code)) ..
- "button_exit[0,6;3,0.8;worldedit_gui_lua_run;Run Lua]" ..
- "button_exit[5,6;3,0.8;worldedit_gui_lua_transform;Lua Transform]"
+ local width, height, length = gui_distance1[name], gui_distance2[name], gui_distance3[name]
+ local node = gui_nodename1[name]
+ local nodename = worldedit.normalize_nodename(node)
+ return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_cube") ..
+ string.format("field[0.5,1.5;4,0.8;worldedit_gui_cube_node;Name;%s]", minetest.formspec_escape(node)) ..
+ "button[4,1.18;1.5,0.8;worldedit_gui_cube_search;Search]" ..
+ formspec_node("5.5,1.1", nodename) ..
+ string.format("field[0.5,2.5;1,0.8;worldedit_gui_cube_width;Width;%s]", minetest.formspec_escape(width)) ..
+ string.format("field[1.5,2.5;1,0.8;worldedit_gui_cube_height;Height;%s]", minetest.formspec_escape(height)) ..
+ string.format("field[2.5,2.5;1,0.8;worldedit_gui_cube_length;Length;%s]", minetest.formspec_escape(length)) ..
+ "button_exit[0,3.5;3,0.8;worldedit_gui_cube_submit_hollow;Hollow Cuboid]" ..
+ "button_exit[3.5,3.5;3,0.8;worldedit_gui_cube_submit_solid;Solid Cuboid]"
end,
})
-worldedit.register_gui_handler("worldedit_gui_lua", function(name, fields)
- if fields.worldedit_gui_lua_run or fields.worldedit_gui_lua_transform then
- gui_code[name] = fields.worldedit_gui_lua_code
- worldedit.show_page(name, "worldedit_gui_lua")
- if fields.worldedit_gui_lua_run then
- minetest.chatcommands["/lua"].func(name, gui_code[name])
- else --fields.worldedit_gui_lua_transform
- minetest.chatcommands["/luatransform"].func(name, gui_code[name])
+worldedit.register_gui_handler("worldedit_gui_cube", function(name, fields)
+ if fields.worldedit_gui_cube_search
+ or fields.worldedit_gui_cube_submit_hollow or fields.worldedit_gui_cube_submit_solid then
+ gui_nodename1[name] = tostring(fields.worldedit_gui_cube_node)
+ gui_distance1[name] = tostring(fields.worldedit_gui_cube_width)
+ gui_distance2[name] = tostring(fields.worldedit_gui_cube_height)
+ gui_distance3[name] = tostring(fields.worldedit_gui_cube_length)
+ worldedit.show_page(name, "worldedit_gui_cube")
+
+ local submit = nil
+ if fields.worldedit_gui_cube_submit_hollow then
+ submit = "hollowcube"
+ elseif fields.worldedit_gui_cube_submit_solid then
+ submit = "cube"
+ end
+ if submit then
+ local n = worldedit.normalize_nodename(gui_nodename1[name])
+ if n then
+ local args = string.format("%s %s %s %s", gui_distance1[name], gui_distance2[name], gui_distance3[name], n)
+ minetest.chatcommands["/"..submit].func(name, args)
+ end
end
return true
end