functionality.lua 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  1. --saved state for each player
  2. local gui_nodename1 = {} --mapping of player names to node names
  3. local gui_nodename2 = {} --mapping of player names to node names
  4. 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)
  5. 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)
  6. local gui_distance1 = {} --mapping of player names to a distance (arbitrary strings may also appear as values)
  7. local gui_distance2 = {} --mapping of player names to a distance (arbitrary strings may also appear as values)
  8. local gui_distance3 = {} --mapping of player names to a distance (arbitrary strings may also appear as values)
  9. local gui_count1 = {} --mapping of player names to a quantity (arbitrary strings may also appear as values)
  10. local gui_count2 = {} --mapping of player names to a quantity (arbitrary strings may also appear as values)
  11. local gui_count3 = {} --mapping of player names to a quantity (arbitrary strings may also appear as values)
  12. local gui_angle = {} --mapping of player names to an angle (one of 90, 180, 270, representing the angle in degrees clockwise)
  13. local gui_filename = {} --mapping of player names to file names
  14. --set default values
  15. setmetatable(gui_nodename1, {__index = function() return "Cobblestone" end})
  16. setmetatable(gui_nodename2, {__index = function() return "Stone" end})
  17. setmetatable(gui_axis1, {__index = function() return 4 end})
  18. setmetatable(gui_axis2, {__index = function() return 1 end})
  19. setmetatable(gui_distance1, {__index = function() return "10" end})
  20. setmetatable(gui_distance2, {__index = function() return "5" end})
  21. setmetatable(gui_distance3, {__index = function() return "2" end})
  22. setmetatable(gui_count1, {__index = function() return "3" end})
  23. setmetatable(gui_count2, {__index = function() return "6" end})
  24. setmetatable(gui_count3, {__index = function() return "4" end})
  25. setmetatable(gui_angle, {__index = function() return 90 end})
  26. setmetatable(gui_filename, {__index = function() return "building" end})
  27. local axis_indices = {["X axis"]=1, ["Y axis"]=2, ["Z axis"]=3, ["Look direction"]=4}
  28. local axis_values = {"x", "y", "z", "?"}
  29. setmetatable(axis_indices, {__index = function () return 4 end})
  30. setmetatable(axis_values, {__index = function () return "?" end})
  31. local angle_indices = {["90 degrees"]=1, ["180 degrees"]=2, ["270 degrees"]=3}
  32. local angle_values = {90, 180, 270}
  33. setmetatable(angle_indices, {__index = function () return 1 end})
  34. setmetatable(angle_values, {__index = function () return 90 end})
  35. -- 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
  36. local combine_privs = function(...)
  37. local result = {}
  38. for i, privs in ipairs({...}) do
  39. for name, value in pairs(privs) do
  40. if result[name] ~= nil and result[name] ~= value then --the priv must be both true and false, which can never happen
  41. return {__fake_priv_that_nobody_has__=true} --privilege table that can never be satisfied
  42. end
  43. result[name] = value
  44. end
  45. end
  46. return result
  47. end
  48. -- display node (or unknown_node image otherwise) at specified pos in formspec
  49. local formspec_node = function(pos, nodename)
  50. local ndef = nodename and minetest.registered_nodes[nodename]
  51. if nodename and ndef then
  52. return string.format("item_image[%s;1,1;%s]", pos, nodename) ..
  53. string.format("tooltip[%s;1,1;%s]", pos, minetest.formspec_escape(ndef.description))
  54. else
  55. return string.format("image[%s;1,1;worldedit_gui_unknown.png]", pos)
  56. end
  57. end
  58. -- two further priv helpers
  59. local function we_privs(command)
  60. return worldedit.registered_commands[command].privs
  61. end
  62. local function combine_we_privs(list)
  63. local args = {}
  64. for _, t in ipairs(list) do
  65. table.insert(args, we_privs(t))
  66. end
  67. return combine_privs(unpack(args))
  68. end
  69. -- functions that handle value changing & page reshowing (without submitting)
  70. local function copy_changes(name, fields, def)
  71. for field, into in pairs(def) do
  72. if into ~= true and fields[field] then
  73. local value = tostring(fields[field])
  74. if into == gui_axis1 or into == gui_axis2 then
  75. into[name] = axis_indices[value]
  76. elseif into == gui_angle then
  77. into[name] = angle_indices[value]
  78. else
  79. into[name] = value
  80. end
  81. end
  82. end
  83. end
  84. local function handle_changes(name, identifier, fields, def)
  85. local any = false
  86. for field, into in pairs(def) do
  87. if fields.key_enter_field == field then
  88. any = true
  89. end
  90. -- first condition: buttons (value not saved)
  91. -- others: dropdowns which will be sent when their value changes
  92. if into == true or into == gui_axis1 or into == gui_axis2 or into == gui_angle then
  93. if fields[field] then
  94. any = true
  95. end
  96. end
  97. end
  98. if not any then
  99. return false
  100. end
  101. any = false
  102. for field, into in pairs(def) do
  103. if into ~= true and fields[field] then
  104. local value = tostring(fields[field])
  105. if into == gui_axis1 or into == gui_axis2 then
  106. into[name] = axis_indices[value]
  107. elseif into == gui_angle then
  108. into[name] = angle_indices[value]
  109. else
  110. into[name] = value
  111. end
  112. if into == gui_nodename1 or into == gui_nodename2 then
  113. any = true
  114. end
  115. end
  116. end
  117. -- Only nodename fields change based on the value, so only re-show the page if necessary
  118. if any then
  119. worldedit.show_page(name, identifier)
  120. end
  121. return true
  122. end
  123. -- This has the same behaviour as the player invoking the chat command
  124. local function execute_worldedit_command(command_name, player_name, params)
  125. local chatcmd = minetest.registered_chatcommands["/" .. command_name]
  126. assert(chatcmd, "unknown command: " .. command_name)
  127. local _, msg = chatcmd.func(player_name, params)
  128. if msg then
  129. worldedit.player_notify(player_name, msg)
  130. end
  131. end
  132. worldedit.register_gui_function("worldedit_gui_about", {
  133. name = "About",
  134. privs = {interact=true},
  135. on_select = function(name)
  136. execute_worldedit_command("about", name, "")
  137. end,
  138. })
  139. worldedit.register_gui_function("worldedit_gui_inspect", {
  140. name = "Toggle Inspect",
  141. privs = we_privs("inspect"),
  142. on_select = function(name)
  143. execute_worldedit_command("inspect", name,
  144. worldedit.inspect[name] and "disable" or "enable")
  145. end,
  146. })
  147. worldedit.register_gui_function("worldedit_gui_region", {
  148. name = "Get/Set Region",
  149. privs = combine_we_privs({"p", "pos1", "pos2", "reset", "mark", "unmark", "volume", "fixedpos"}),
  150. get_formspec = function(name)
  151. local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
  152. return "size[9,7]" .. worldedit.get_formspec_header("worldedit_gui_region") ..
  153. "button_exit[0,1;3,0.8;worldedit_gui_p_get;Get Positions]" ..
  154. "button_exit[3,1;3,0.8;worldedit_gui_p_set1;Choose Position 1]" ..
  155. "button_exit[6,1;3,0.8;worldedit_gui_p_set2;Choose Position 2]" ..
  156. "button_exit[0,2;3,0.8;worldedit_gui_pos1;Position 1 Here]" ..
  157. "button_exit[3,2;3,0.8;worldedit_gui_pos2;Position 2 Here]" ..
  158. "button_exit[6,2;3,0.8;worldedit_gui_reset;Reset Region]" ..
  159. "button_exit[0,3;3,0.8;worldedit_gui_mark;Mark Region]" ..
  160. "button_exit[3,3;3,0.8;worldedit_gui_unmark;Unmark Region]" ..
  161. "button_exit[6,3;3,0.8;worldedit_gui_volume;Region Volume]" ..
  162. "label[0,4.7;Position 1]" ..
  163. string.format("field[2,5;1.5,0.8;worldedit_gui_fixedpos_pos1x;X ;%s]", pos1 and pos1.x or "") ..
  164. string.format("field[3.5,5;1.5,0.8;worldedit_gui_fixedpos_pos1y;Y ;%s]", pos1 and pos1.y or "") ..
  165. string.format("field[5,5;1.5,0.8;worldedit_gui_fixedpos_pos1z;Z ;%s]", pos1 and pos1.z or "") ..
  166. "button_exit[6.5,4.68;2.5,0.8;worldedit_gui_fixedpos_pos1_submit;Set Position 1]" ..
  167. "label[0,6.2;Position 2]" ..
  168. string.format("field[2,6.5;1.5,0.8;worldedit_gui_fixedpos_pos2x;X ;%s]", pos2 and pos2.x or "") ..
  169. string.format("field[3.5,6.5;1.5,0.8;worldedit_gui_fixedpos_pos2y;Y ;%s]", pos2 and pos2.y or "") ..
  170. string.format("field[5,6.5;1.5,0.8;worldedit_gui_fixedpos_pos2z;Z ;%s]", pos2 and pos2.z or "") ..
  171. "button_exit[6.5,6.18;2.5,0.8;worldedit_gui_fixedpos_pos2_submit;Set Position 2]"
  172. end,
  173. })
  174. worldedit.register_gui_handler("worldedit_gui_region", function(name, fields)
  175. if fields.worldedit_gui_p_get then
  176. execute_worldedit_command("p", name, "get")
  177. return true
  178. elseif fields.worldedit_gui_p_set1 then
  179. execute_worldedit_command("p", name, "set1")
  180. return true
  181. elseif fields.worldedit_gui_p_set2 then
  182. execute_worldedit_command("p", name, "set2")
  183. return true
  184. elseif fields.worldedit_gui_pos1 then
  185. execute_worldedit_command("pos1", name, "")
  186. worldedit.show_page(name, "worldedit_gui_region")
  187. return true
  188. elseif fields.worldedit_gui_pos2 then
  189. execute_worldedit_command("pos2", name, "")
  190. worldedit.show_page(name, "worldedit_gui_region")
  191. return true
  192. elseif fields.worldedit_gui_reset then
  193. execute_worldedit_command("reset", name, "")
  194. worldedit.show_page(name, "worldedit_gui_region")
  195. return true
  196. elseif fields.worldedit_gui_mark then
  197. execute_worldedit_command("mark", name, "")
  198. worldedit.show_page(name, "worldedit_gui_region")
  199. return true
  200. elseif fields.worldedit_gui_unmark then
  201. execute_worldedit_command("unmark", name, "")
  202. worldedit.show_page(name, "worldedit_gui_region")
  203. return true
  204. elseif fields.worldedit_gui_volume then
  205. execute_worldedit_command("volume", name, "")
  206. worldedit.show_page(name, "worldedit_gui_region")
  207. return true
  208. elseif fields.worldedit_gui_fixedpos_pos1_submit then
  209. execute_worldedit_command("fixedpos", name, ("set1 %s %s %s"):format(
  210. tostring(fields.worldedit_gui_fixedpos_pos1x),
  211. tostring(fields.worldedit_gui_fixedpos_pos1y),
  212. tostring(fields.worldedit_gui_fixedpos_pos1z)))
  213. worldedit.show_page(name, "worldedit_gui_region")
  214. return true
  215. elseif fields.worldedit_gui_fixedpos_pos2_submit then
  216. execute_worldedit_command("fixedpos", name, ("set2 %s %s %s"):format(
  217. tostring(fields.worldedit_gui_fixedpos_pos2x),
  218. tostring(fields.worldedit_gui_fixedpos_pos2y),
  219. tostring(fields.worldedit_gui_fixedpos_pos2z)))
  220. worldedit.show_page(name, "worldedit_gui_region")
  221. return true
  222. end
  223. return false
  224. end)
  225. worldedit.register_gui_function("worldedit_gui_set", {
  226. name = "Set Nodes",
  227. privs = we_privs("set"),
  228. get_formspec = function(name)
  229. local node = gui_nodename1[name]
  230. local nodename = worldedit.normalize_nodename(node)
  231. return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_set") ..
  232. string.format("field[0.5,1.5;4,0.8;worldedit_gui_set_node;Name;%s]", minetest.formspec_escape(node)) ..
  233. "field_close_on_enter[worldedit_gui_set_node;false]" ..
  234. "button[4,1.18;1.5,0.8;worldedit_gui_set_search;Search]" ..
  235. formspec_node("5.5,1.1", nodename) ..
  236. "button_exit[0,2.5;3,0.8;worldedit_gui_set_submit;Set Nodes]"
  237. end,
  238. })
  239. worldedit.register_gui_handler("worldedit_gui_set", function(name, fields)
  240. local cg = {
  241. worldedit_gui_set_search = true,
  242. worldedit_gui_set_node = gui_nodename1,
  243. }
  244. local ret = handle_changes(name, "worldedit_gui_set", fields, cg)
  245. if fields.worldedit_gui_set_submit then
  246. copy_changes(name, fields, cg)
  247. worldedit.show_page(name, "worldedit_gui_set")
  248. local n = worldedit.normalize_nodename(gui_nodename1[name])
  249. if n then
  250. execute_worldedit_command("set", name, n)
  251. end
  252. return true
  253. end
  254. return ret
  255. end)
  256. worldedit.register_gui_function("worldedit_gui_replace", {
  257. name = "Replace Nodes",
  258. privs = combine_we_privs({"replace", "replaceinverse"}),
  259. get_formspec = function(name)
  260. local search, replace = gui_nodename1[name], gui_nodename2[name]
  261. local search_nodename, replace_nodename = worldedit.normalize_nodename(search), worldedit.normalize_nodename(replace)
  262. return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_replace") ..
  263. string.format("field[0.5,1.5;4,0.8;worldedit_gui_replace_search;Name;%s]", minetest.formspec_escape(search)) ..
  264. "field_close_on_enter[worldedit_gui_replace_search;false]" ..
  265. "button[4,1.18;1.5,0.8;worldedit_gui_replace_search_search;Search]" ..
  266. formspec_node("5.5,1.1", search_nodename) ..
  267. string.format("field[0.5,2.5;4,0.8;worldedit_gui_replace_replace;Name;%s]", minetest.formspec_escape(replace)) ..
  268. "field_close_on_enter[worldedit_gui_replace_replace;false]" ..
  269. "button[4,2.18;1.5,0.8;worldedit_gui_replace_replace_search;Search]" ..
  270. formspec_node("5.5,2.1", replace_nodename) ..
  271. "button_exit[0,3.5;3,0.8;worldedit_gui_replace_submit;Replace Nodes]" ..
  272. "button_exit[3.5,3.5;3,0.8;worldedit_gui_replace_submit_inverse;Replace Inverse]"
  273. end,
  274. })
  275. worldedit.register_gui_handler("worldedit_gui_replace", function(name, fields)
  276. local cg = {
  277. worldedit_gui_replace_search_search = true,
  278. worldedit_gui_replace_replace_search = true,
  279. worldedit_gui_replace_search = gui_nodename1,
  280. worldedit_gui_replace_replace = gui_nodename2,
  281. }
  282. local ret = handle_changes(name, "worldedit_gui_replace", fields, cg)
  283. if fields.worldedit_gui_replace_submit or fields.worldedit_gui_replace_submit_inverse then
  284. copy_changes(name, fields, cg)
  285. worldedit.show_page(name, "worldedit_gui_replace")
  286. local submit = "replace"
  287. if fields.worldedit_gui_replace_submit_inverse then
  288. submit = "replaceinverse"
  289. end
  290. local n1 = worldedit.normalize_nodename(gui_nodename1[name])
  291. local n2 = worldedit.normalize_nodename(gui_nodename2[name])
  292. if n1 and n2 then
  293. execute_worldedit_command(submit, name, n1 .. " " .. n2)
  294. end
  295. return true
  296. end
  297. return ret
  298. end)
  299. worldedit.register_gui_function("worldedit_gui_sphere_dome", {
  300. name = "Sphere/Dome",
  301. privs = combine_we_privs({"hollowsphere", "sphere", "hollowdome", "dome"}),
  302. get_formspec = function(name)
  303. local node, radius = gui_nodename1[name], gui_distance2[name]
  304. local nodename = worldedit.normalize_nodename(node)
  305. return "size[6.5,5]" .. worldedit.get_formspec_header("worldedit_gui_sphere_dome") ..
  306. string.format("field[0.5,1.5;4,0.8;worldedit_gui_sphere_dome_node;Name;%s]", minetest.formspec_escape(node)) ..
  307. "field_close_on_enter[worldedit_gui_sphere_dome_node;false]" ..
  308. "button[4,1.18;1.5,0.8;worldedit_gui_sphere_dome_search;Search]" ..
  309. formspec_node("5.5,1.1", nodename) ..
  310. string.format("field[0.5,2.5;4,0.8;worldedit_gui_sphere_dome_radius;Radius;%s]", minetest.formspec_escape(radius)) ..
  311. "field_close_on_enter[worldedit_gui_sphere_dome_radius;false]" ..
  312. "button_exit[0,3.5;3,0.8;worldedit_gui_sphere_dome_submit_hollow;Hollow Sphere]" ..
  313. "button_exit[3.5,3.5;3,0.8;worldedit_gui_sphere_dome_submit_solid;Solid Sphere]" ..
  314. "button_exit[0,4.5;3,0.8;worldedit_gui_sphere_dome_submit_hollow_dome;Hollow Dome]" ..
  315. "button_exit[3.5,4.5;3,0.8;worldedit_gui_sphere_dome_submit_solid_dome;Solid Dome]"
  316. end,
  317. })
  318. worldedit.register_gui_handler("worldedit_gui_sphere_dome", function(name, fields)
  319. local cg = {
  320. worldedit_gui_sphere_dome_search = true,
  321. worldedit_gui_sphere_dome_node = gui_nodename1,
  322. worldedit_gui_sphere_dome_radius = gui_distance2,
  323. }
  324. local ret = handle_changes(name, "worldedit_gui_sphere_dome", fields, cg)
  325. if fields.worldedit_gui_sphere_dome_submit_hollow or fields.worldedit_gui_sphere_dome_submit_solid
  326. or fields.worldedit_gui_sphere_dome_submit_hollow_dome or fields.worldedit_gui_sphere_dome_submit_solid_dome then
  327. copy_changes(name, fields, cg)
  328. worldedit.show_page(name, "worldedit_gui_sphere_dome")
  329. local submit = "hollowsphere"
  330. if fields.worldedit_gui_sphere_dome_submit_solid then
  331. submit = "sphere"
  332. elseif fields.worldedit_gui_sphere_dome_submit_hollow_dome then
  333. submit = "hollowdome"
  334. elseif fields.worldedit_gui_sphere_dome_submit_solid_dome then
  335. submit = "dome"
  336. end
  337. local n = worldedit.normalize_nodename(gui_nodename1[name])
  338. if n then
  339. execute_worldedit_command(submit, name,
  340. gui_distance2[name] .. " " .. n)
  341. end
  342. return true
  343. end
  344. return ret
  345. end)
  346. worldedit.register_gui_function("worldedit_gui_cylinder", {
  347. name = "Cylinder",
  348. privs = combine_we_privs({"hollowcylinder", "cylinder"}),
  349. get_formspec = function(name)
  350. local node, axis, length = gui_nodename1[name], gui_axis1[name], gui_distance1[name]
  351. local radius1, radius2 = gui_distance2[name], gui_distance3[name]
  352. local nodename = worldedit.normalize_nodename(node)
  353. return "size[6.5,6]" .. worldedit.get_formspec_header("worldedit_gui_cylinder") ..
  354. string.format("field[0.5,1.5;4,0.8;worldedit_gui_cylinder_node;Name;%s]", minetest.formspec_escape(node)) ..
  355. "field_close_on_enter[worldedit_gui_cylinder_node;false]" ..
  356. "button[4,1.18;1.5,0.8;worldedit_gui_cylinder_search;Search]" ..
  357. formspec_node("5.5,1.1", nodename) ..
  358. string.format("field[0.5,2.5;4,0.8;worldedit_gui_cylinder_length;Length;%s]", minetest.formspec_escape(length)) ..
  359. string.format("dropdown[4,2.18;2.5;worldedit_gui_cylinder_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
  360. string.format("field[0.5,3.5;2,0.8;worldedit_gui_cylinder_radius1;Base Radius;%s]", minetest.formspec_escape(radius1)) ..
  361. string.format("field[2.5,3.5;2,0.8;worldedit_gui_cylinder_radius2;Top Radius;%s]", minetest.formspec_escape(radius2)) ..
  362. "field_close_on_enter[worldedit_gui_cylinder_length;false]" ..
  363. "field_close_on_enter[worldedit_gui_cylinder_radius1;false]" ..
  364. "field_close_on_enter[worldedit_gui_cylinder_radius2;false]" ..
  365. "label[0.25,4;Equal base and top radius creates a cylinder,\n"..
  366. "zero top radius creates a cone.\nConsult documentation for more information.]"..
  367. "button_exit[0,5.5;3,0.8;worldedit_gui_cylinder_submit_hollow;Hollow Cylinder]" ..
  368. "button_exit[3.5,5.5;3,0.8;worldedit_gui_cylinder_submit_solid;Solid Cylinder]"
  369. end,
  370. })
  371. worldedit.register_gui_handler("worldedit_gui_cylinder", function(name, fields)
  372. local cg = {
  373. worldedit_gui_cylinder_search = true,
  374. worldedit_gui_cylinder_node = gui_nodename1,
  375. worldedit_gui_cylinder_axis = gui_axis1,
  376. worldedit_gui_cylinder_length = gui_distance1,
  377. worldedit_gui_cylinder_radius1 = gui_distance2,
  378. worldedit_gui_cylinder_radius2 = gui_distance3,
  379. }
  380. local ret = handle_changes(name, "worldedit_gui_cylinder", fields, cg)
  381. if fields.worldedit_gui_cylinder_submit_hollow or fields.worldedit_gui_cylinder_submit_solid then
  382. copy_changes(name, fields, cg)
  383. worldedit.show_page(name, "worldedit_gui_cylinder")
  384. local submit = "hollowcylinder"
  385. if fields.worldedit_gui_cylinder_submit_solid then
  386. submit = "cylinder"
  387. end
  388. local n = worldedit.normalize_nodename(gui_nodename1[name])
  389. if n then
  390. local args = string.format("%s %s %s %s %s", axis_values[gui_axis1[name]], gui_distance1[name], gui_distance2[name], gui_distance3[name], n)
  391. execute_worldedit_command(submit, name, args)
  392. end
  393. return true
  394. end
  395. return ret
  396. end)
  397. worldedit.register_gui_function("worldedit_gui_pyramid", {
  398. name = "Pyramid",
  399. privs = we_privs("pyramid"),
  400. get_formspec = function(name)
  401. local node, axis, length = gui_nodename1[name], gui_axis1[name], gui_distance1[name]
  402. local nodename = worldedit.normalize_nodename(node)
  403. return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_pyramid") ..
  404. string.format("field[0.5,1.5;4,0.8;worldedit_gui_pyramid_node;Name;%s]", minetest.formspec_escape(node)) ..
  405. "field_close_on_enter[worldedit_gui_pyramid_node;false]" ..
  406. "button[4,1.18;1.5,0.8;worldedit_gui_pyramid_search;Search]" ..
  407. formspec_node("5.5,1.1", nodename) ..
  408. string.format("field[0.5,2.5;4,0.8;worldedit_gui_pyramid_length;Length;%s]", minetest.formspec_escape(length)) ..
  409. string.format("dropdown[4,2.18;2.5;worldedit_gui_pyramid_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
  410. "field_close_on_enter[worldedit_gui_pyramid_length;false]" ..
  411. "button_exit[0,3.5;3,0.8;worldedit_gui_pyramid_submit_hollow;Hollow Pyramid]" ..
  412. "button_exit[3.5,3.5;3,0.8;worldedit_gui_pyramid_submit_solid;Solid Pyramid]"
  413. end,
  414. })
  415. worldedit.register_gui_handler("worldedit_gui_pyramid", function(name, fields)
  416. local cg = {
  417. worldedit_gui_pyramid_search = true,
  418. worldedit_gui_pyramid_node = gui_nodename1,
  419. worldedit_gui_pyramid_axis = gui_axis1,
  420. worldedit_gui_pyramid_length = gui_distance1,
  421. }
  422. local ret = handle_changes(name, "worldedit_gui_pyramid", fields, cg)
  423. if fields.worldedit_gui_pyramid_submit_solid or fields.worldedit_gui_pyramid_submit_hollow then
  424. copy_changes(name, fields, cg)
  425. worldedit.show_page(name, "worldedit_gui_pyramid")
  426. local submit = "pyramid"
  427. if fields.worldedit_gui_pyramid_submit_hollow then
  428. submit = "hollowpyramid"
  429. end
  430. local n = worldedit.normalize_nodename(gui_nodename1[name])
  431. if n then
  432. execute_worldedit_command(submit, name,
  433. string.format("%s %s %s", axis_values[gui_axis1[name]],
  434. gui_distance1[name], n))
  435. end
  436. return true
  437. end
  438. return ret
  439. end)
  440. worldedit.register_gui_function("worldedit_gui_spiral", {
  441. name = "Spiral",
  442. privs = we_privs("spiral"),
  443. get_formspec = function(name)
  444. local node, length, height, space = gui_nodename1[name], gui_distance1[name], gui_distance2[name], gui_distance3[name]
  445. local nodename = worldedit.normalize_nodename(node)
  446. return "size[6.5,6]" .. worldedit.get_formspec_header("worldedit_gui_spiral") ..
  447. string.format("field[0.5,1.5;4,0.8;worldedit_gui_spiral_node;Name;%s]", minetest.formspec_escape(node)) ..
  448. "field_close_on_enter[worldedit_gui_spiral_node;false]" ..
  449. "button[4,1.18;1.5,0.8;worldedit_gui_spiral_search;Search]" ..
  450. formspec_node("5.5,1.1", nodename) ..
  451. string.format("field[0.5,2.5;4,0.8;worldedit_gui_spiral_length;Side Length;%s]", minetest.formspec_escape(length)) ..
  452. string.format("field[0.5,3.5;4,0.8;worldedit_gui_spiral_height;Height;%s]", minetest.formspec_escape(height)) ..
  453. string.format("field[0.5,4.5;4,0.8;worldedit_gui_spiral_space;Wall Spacing;%s]", minetest.formspec_escape(space)) ..
  454. "field_close_on_enter[worldedit_gui_spiral_length;false]" ..
  455. "field_close_on_enter[worldedit_gui_spiral_height;false]" ..
  456. "field_close_on_enter[worldedit_gui_spiral_space;false]" ..
  457. "button_exit[0,5.5;3,0.8;worldedit_gui_spiral_submit;Spiral]"
  458. end,
  459. })
  460. worldedit.register_gui_handler("worldedit_gui_spiral", function(name, fields)
  461. local cg = {
  462. worldedit_gui_spiral_search = true,
  463. worldedit_gui_spiral_node = gui_nodename1,
  464. worldedit_gui_spiral_length = gui_distance1,
  465. worldedit_gui_spiral_height = gui_distance2,
  466. worldedit_gui_spiral_space = gui_distance3,
  467. }
  468. local ret = handle_changes(name, "worldedit_gui_spiral", fields, cg)
  469. if fields.worldedit_gui_spiral_submit then
  470. copy_changes(name, fields, cg)
  471. worldedit.show_page(name, "worldedit_gui_spiral")
  472. local n = worldedit.normalize_nodename(gui_nodename1[name])
  473. if n then
  474. execute_worldedit_command("spiral", name,
  475. string.format("%s %s %s %s", gui_distance1[name],
  476. gui_distance2[name], gui_distance3[name], n))
  477. end
  478. return true
  479. end
  480. return ret
  481. end)
  482. worldedit.register_gui_function("worldedit_gui_copy_move", {
  483. name = "Copy/Move",
  484. privs = combine_we_privs({"copy", "move"}),
  485. get_formspec = function(name)
  486. local axis = gui_axis1[name] or 4
  487. local amount = gui_distance1[name] or "10"
  488. return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_copy_move") ..
  489. string.format("field[0.5,1.5;4,0.8;worldedit_gui_copy_move_amount;Amount;%s]", minetest.formspec_escape(amount)) ..
  490. string.format("dropdown[4,1.18;2.5;worldedit_gui_copy_move_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
  491. "field_close_on_enter[worldedit_gui_copy_move_amount;false]" ..
  492. "button_exit[0,2.5;3,0.8;worldedit_gui_copy_move_copy;Copy Region]" ..
  493. "button_exit[3.5,2.5;3,0.8;worldedit_gui_copy_move_move;Move Region]"
  494. end,
  495. })
  496. worldedit.register_gui_handler("worldedit_gui_copy_move", function(name, fields)
  497. local cg = {
  498. worldedit_gui_copy_move_amount = gui_distance1,
  499. worldedit_gui_copy_move_axis = gui_axis1,
  500. }
  501. local ret = handle_changes(name, "worldedit_gui_spiral", fields, cg)
  502. if fields.worldedit_gui_copy_move_copy or fields.worldedit_gui_copy_move_move then
  503. copy_changes(name, fields, cg)
  504. worldedit.show_page(name, "worldedit_gui_copy_move")
  505. local submit = "copy"
  506. if fields.worldedit_gui_copy_move_move then
  507. submit = "move"
  508. end
  509. execute_worldedit_command(submit, name,
  510. axis_values[gui_axis1[name]] .. " " .. gui_distance1[name])
  511. return true
  512. end
  513. return ret
  514. end)
  515. worldedit.register_gui_function("worldedit_gui_stack", {
  516. name = "Stack",
  517. privs = we_privs("stack"),
  518. get_formspec = function(name)
  519. local axis, count = gui_axis1[name], gui_count1[name]
  520. return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_stack") ..
  521. string.format("field[0.5,1.5;4,0.8;worldedit_gui_stack_count;Count;%s]", minetest.formspec_escape(count)) ..
  522. string.format("dropdown[4,1.18;2.5;worldedit_gui_stack_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
  523. "field_close_on_enter[worldedit_gui_stack_count;false]" ..
  524. "button_exit[0,2.5;3,0.8;worldedit_gui_stack_submit;Stack]"
  525. end,
  526. })
  527. worldedit.register_gui_handler("worldedit_gui_stack", function(name, fields)
  528. local cg = {
  529. worldedit_gui_stack_axis = gui_axis1,
  530. worldedit_gui_stack_count = gui_count1,
  531. }
  532. local ret = handle_changes(name, "worldedit_gui_stack", fields, cg)
  533. if fields.worldedit_gui_stack_submit then
  534. copy_changes(name, fields, cg)
  535. worldedit.show_page(name, "worldedit_gui_stack")
  536. execute_worldedit_command("stack", name,
  537. axis_values[gui_axis1[name]] .. " " .. gui_count1[name])
  538. return true
  539. end
  540. return ret
  541. end)
  542. worldedit.register_gui_function("worldedit_gui_stretch", {
  543. name = "Stretch",
  544. privs = we_privs("stretch"),
  545. get_formspec = function(name)
  546. local stretchx, stretchy, stretchz = gui_count1[name], gui_count2[name], gui_count3[name]
  547. return "size[5,5]" .. worldedit.get_formspec_header("worldedit_gui_stretch") ..
  548. string.format("field[0.5,1.5;4,0.8;worldedit_gui_stretch_x;Stretch X;%s]", minetest.formspec_escape(stretchx)) ..
  549. string.format("field[0.5,2.5;4,0.8;worldedit_gui_stretch_y;Stretch Y;%s]", minetest.formspec_escape(stretchy)) ..
  550. string.format("field[0.5,3.5;4,0.8;worldedit_gui_stretch_z;Stretch Z;%s]", minetest.formspec_escape(stretchz)) ..
  551. "field_close_on_enter[worldedit_gui_stretch_x;false]" ..
  552. "field_close_on_enter[worldedit_gui_stretch_y;false]" ..
  553. "field_close_on_enter[worldedit_gui_stretch_z;false]" ..
  554. "button_exit[0,4.5;3,0.8;worldedit_gui_stretch_submit;Stretch]"
  555. end,
  556. })
  557. worldedit.register_gui_handler("worldedit_gui_stretch", function(name, fields)
  558. local cg = {
  559. worldedit_gui_stretch_x = gui_count1,
  560. worldedit_gui_stretch_y = gui_count2,
  561. worldedit_gui_stretch_z = gui_count3,
  562. }
  563. local ret = handle_changes(name, "worldedit_gui_stretch", fields, cg)
  564. if fields.worldedit_gui_stretch_submit then
  565. copy_changes(name, fields, cg)
  566. worldedit.show_page(name, "worldedit_gui_stretch")
  567. execute_worldedit_command("stretch", name, string.format("%s %s %s",
  568. gui_count1[name], gui_count2[name], gui_count3[name]))
  569. return true
  570. end
  571. return ret
  572. end)
  573. worldedit.register_gui_function("worldedit_gui_transpose", {
  574. name = "Transpose",
  575. privs = we_privs("transpose"),
  576. get_formspec = function(name)
  577. local axis1, axis2 = gui_axis1[name], gui_axis2[name]
  578. return "size[5.5,3]" .. worldedit.get_formspec_header("worldedit_gui_transpose") ..
  579. string.format("dropdown[0,1;2.5;worldedit_gui_transpose_axis1;X axis,Y axis,Z axis,Look direction;%d]", axis1) ..
  580. string.format("dropdown[3,1;2.5;worldedit_gui_transpose_axis2;X axis,Y axis,Z axis,Look direction;%d]", axis2) ..
  581. "button_exit[0,2.5;3,0.8;worldedit_gui_transpose_submit;Transpose]"
  582. end,
  583. })
  584. worldedit.register_gui_handler("worldedit_gui_transpose", function(name, fields)
  585. local cg = {
  586. worldedit_gui_transpose_axis1 = gui_axis1,
  587. worldedit_gui_transpose_axis2 = gui_axis2,
  588. }
  589. local ret = handle_changes(name, "worldedit_gui_transpose", fields, cg)
  590. if fields.worldedit_gui_transpose_submit then
  591. copy_changes(name, fields, cg)
  592. execute_worldedit_command("transpose", name,
  593. axis_values[gui_axis1[name]] .. " " .. axis_values[gui_axis2[name]])
  594. return true
  595. end
  596. return ret
  597. end)
  598. worldedit.register_gui_function("worldedit_gui_flip", {
  599. name = "Flip",
  600. privs = we_privs("flip"),
  601. get_formspec = function(name)
  602. local axis = gui_axis1[name]
  603. return "size[5,3]" .. worldedit.get_formspec_header("worldedit_gui_flip") ..
  604. string.format("dropdown[0,1;2.5;worldedit_gui_flip_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
  605. "button_exit[0,2.5;3,0.8;worldedit_gui_flip_submit;Flip]"
  606. end,
  607. })
  608. worldedit.register_gui_handler("worldedit_gui_flip", function(name, fields)
  609. local cg = {
  610. worldedit_gui_flip_axis = gui_axis1
  611. }
  612. local ret = handle_changes(name, "worldedit_gui_flip", fields, cg)
  613. if fields.worldedit_gui_flip_submit then
  614. copy_changes(name, fields, cg)
  615. worldedit.show_page(name, "worldedit_gui_flip")
  616. execute_worldedit_command("flip", name, axis_values[gui_axis1[name]])
  617. return true
  618. end
  619. return ret
  620. end)
  621. worldedit.register_gui_function("worldedit_gui_rotate", {
  622. name = "Rotate",
  623. privs = we_privs("rotate"),
  624. get_formspec = function(name)
  625. local axis, angle = gui_axis1[name], gui_angle[name]
  626. return "size[5.5,3]" .. worldedit.get_formspec_header("worldedit_gui_rotate") ..
  627. string.format("dropdown[0,1;2.5;worldedit_gui_rotate_angle;90 degrees,180 degrees,270 degrees;%s]", angle) ..
  628. string.format("dropdown[3,1;2.5;worldedit_gui_rotate_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
  629. "button_exit[0,2.5;3,0.8;worldedit_gui_rotate_submit;Rotate]"
  630. end,
  631. })
  632. worldedit.register_gui_handler("worldedit_gui_rotate", function(name, fields)
  633. local cg = {
  634. worldedit_gui_rotate_axis = gui_axis1,
  635. worldedit_gui_rotate_angle = gui_angle,
  636. }
  637. local ret = handle_changes(name, "worldedit_gui_rotate", fields, cg)
  638. if fields.worldedit_gui_rotate_submit then
  639. copy_changes(name, fields, cg)
  640. worldedit.show_page(name, "worldedit_gui_rotate")
  641. execute_worldedit_command("rotate", name,
  642. axis_values[gui_axis1[name]] .. " " .. angle_values[gui_angle[name]])
  643. return true
  644. end
  645. return ret
  646. end)
  647. worldedit.register_gui_function("worldedit_gui_orient", {
  648. name = "Orient",
  649. privs = we_privs("orient"),
  650. get_formspec = function(name)
  651. local angle = gui_angle[name]
  652. return "size[5,3]" .. worldedit.get_formspec_header("worldedit_gui_orient") ..
  653. string.format("dropdown[0,1;2.5;worldedit_gui_orient_angle;90 degrees,180 degrees,270 degrees;%s]", angle) ..
  654. "button_exit[0,2.5;3,0.8;worldedit_gui_orient_submit;Orient]"
  655. end,
  656. })
  657. worldedit.register_gui_handler("worldedit_gui_orient", function(name, fields)
  658. local cg = {
  659. worldedit_gui_orient_angle = gui_angle,
  660. }
  661. local ret = handle_changes(name, "worldedit_gui_orient", fields, cg)
  662. if fields.worldedit_gui_orient_submit then
  663. copy_changes(name, fields, cg)
  664. worldedit.show_page(name, "worldedit_gui_orient")
  665. execute_worldedit_command("orient", name,
  666. tostring(angle_values[gui_angle[name]]))
  667. return true
  668. end
  669. return ret
  670. end)
  671. worldedit.register_gui_function("worldedit_gui_fixlight", {
  672. name = "Fix Lighting",
  673. privs = we_privs("fixlight"),
  674. on_select = function(name)
  675. execute_worldedit_command("fixlight", name, "")
  676. end,
  677. })
  678. worldedit.register_gui_function("worldedit_gui_hide", {
  679. name = "Hide Region",
  680. privs = we_privs("hide"),
  681. on_select = function(name)
  682. execute_worldedit_command("hide", name, "")
  683. end,
  684. })
  685. worldedit.register_gui_function("worldedit_gui_suppress", {
  686. name = "Suppress Nodes",
  687. privs = we_privs("suppress"),
  688. get_formspec = function(name)
  689. local node = gui_nodename1[name]
  690. local nodename = worldedit.normalize_nodename(node)
  691. return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_suppress") ..
  692. string.format("field[0.5,1.5;4,0.8;worldedit_gui_suppress_node;Name;%s]", minetest.formspec_escape(node)) ..
  693. "field_close_on_enter[worldedit_gui_suppress_node;false]" ..
  694. "button[4,1.18;1.5,0.8;worldedit_gui_suppress_search;Search]" ..
  695. formspec_node("5.5,1.1", nodename) ..
  696. "button_exit[0,2.5;3,0.8;worldedit_gui_suppress_submit;Suppress Nodes]"
  697. end,
  698. })
  699. worldedit.register_gui_handler("worldedit_gui_suppress", function(name, fields)
  700. local cg = {
  701. worldedit_gui_suppress_search = true,
  702. worldedit_gui_suppress_node = gui_nodename1,
  703. }
  704. local ret = handle_changes(name, "worldedit_gui_suppress", fields, cg)
  705. if fields.worldedit_gui_suppress_submit then
  706. copy_changes(name, fields, cg)
  707. worldedit.show_page(name, "worldedit_gui_suppress")
  708. local n = worldedit.normalize_nodename(gui_nodename1[name])
  709. if n then
  710. execute_worldedit_command("suppress", name, n)
  711. end
  712. return true
  713. end
  714. return ret
  715. end)
  716. worldedit.register_gui_function("worldedit_gui_highlight", {
  717. name = "Highlight Nodes",
  718. privs = we_privs("highlight"),
  719. get_formspec = function(name)
  720. local node = gui_nodename1[name]
  721. local nodename = worldedit.normalize_nodename(node)
  722. return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_highlight") ..
  723. string.format("field[0.5,1.5;4,0.8;worldedit_gui_highlight_node;Name;%s]", minetest.formspec_escape(node)) ..
  724. "field_close_on_enter[worldedit_gui_highlight_node;false]" ..
  725. "button[4,1.18;1.5,0.8;worldedit_gui_highlight_search;Search]" ..
  726. formspec_node("5.5,1.1", nodename) ..
  727. "button_exit[0,2.5;3,0.8;worldedit_gui_highlight_submit;Highlight Nodes]"
  728. end,
  729. })
  730. worldedit.register_gui_handler("worldedit_gui_highlight", function(name, fields)
  731. local cg = {
  732. worldedit_gui_highlight_search = true,
  733. worldedit_gui_highlight_node = gui_nodename1,
  734. }
  735. local ret = handle_changes(name, "worldedit_gui_highlight", fields, cg)
  736. if fields.worldedit_gui_highlight_submit then
  737. copy_changes(name, fields, cg)
  738. worldedit.show_page(name, "worldedit_gui_highlight")
  739. local n = worldedit.normalize_nodename(gui_nodename1[name])
  740. if n then
  741. execute_worldedit_command("highlight", name, n)
  742. end
  743. return true
  744. end
  745. return ret
  746. end)
  747. worldedit.register_gui_function("worldedit_gui_restore", {
  748. name = "Restore Region",
  749. privs = we_privs("restore"),
  750. on_select = function(name)
  751. execute_worldedit_command("restore", name, "")
  752. end,
  753. })
  754. worldedit.register_gui_function("worldedit_gui_save_load", {
  755. name = "Save/Load",
  756. privs = combine_we_privs({"save", "allocate", "load"}),
  757. get_formspec = function(name)
  758. local filename = gui_filename[name]
  759. return "size[6,4]" .. worldedit.get_formspec_header("worldedit_gui_save_load") ..
  760. string.format("field[0.5,1.5;4,0.8;worldedit_gui_save_filename;Filename;%s]", minetest.formspec_escape(filename)) ..
  761. "field_close_on_enter[worldedit_gui_save_filename;false]" ..
  762. "button_exit[0,2.5;3,0.8;worldedit_gui_save_load_submit_save;Save]" ..
  763. "button_exit[3,2.5;3,0.8;worldedit_gui_save_load_submit_allocate;Allocate]" ..
  764. "button_exit[0,3.5;3,0.8;worldedit_gui_save_load_submit_load;Load]"
  765. end,
  766. })
  767. worldedit.register_gui_handler("worldedit_gui_save_load", function(name, fields)
  768. if fields.worldedit_gui_save_load_submit_save or fields.worldedit_gui_save_load_submit_allocate or fields.worldedit_gui_save_load_submit_load then
  769. gui_filename[name] = tostring(fields.worldedit_gui_save_filename)
  770. worldedit.show_page(name, "worldedit_gui_save_load")
  771. if fields.worldedit_gui_save_load_submit_save then
  772. execute_worldedit_command("save", name, gui_filename[name])
  773. elseif fields.worldedit_gui_save_load_submit_allocate then
  774. execute_worldedit_command("allocate", name, gui_filename[name])
  775. else --fields.worldedit_gui_save_load_submit_load
  776. execute_worldedit_command("load", name, gui_filename[name])
  777. end
  778. return true
  779. end
  780. return false
  781. end)
  782. worldedit.register_gui_function("worldedit_gui_cube", {
  783. name = "Cube",
  784. privs = combine_we_privs({"hollowcube", "cube"}),
  785. get_formspec = function(name)
  786. local width, height, length = gui_distance1[name], gui_distance2[name], gui_distance3[name]
  787. local node = gui_nodename1[name]
  788. local nodename = worldedit.normalize_nodename(node)
  789. return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_cube") ..
  790. string.format("field[0.5,1.5;4,0.8;worldedit_gui_cube_node;Name;%s]", minetest.formspec_escape(node)) ..
  791. "field_close_on_enter[worldedit_gui_cube_node;false]" ..
  792. "button[4,1.18;1.5,0.8;worldedit_gui_cube_search;Search]" ..
  793. formspec_node("5.5,1.1", nodename) ..
  794. string.format("field[0.5,2.5;1,0.8;worldedit_gui_cube_width;Width;%s]", minetest.formspec_escape(width)) ..
  795. string.format("field[1.5,2.5;1,0.8;worldedit_gui_cube_height;Height;%s]", minetest.formspec_escape(height)) ..
  796. string.format("field[2.5,2.5;1,0.8;worldedit_gui_cube_length;Length;%s]", minetest.formspec_escape(length)) ..
  797. "field_close_on_enter[worldedit_gui_cube_width;false]" ..
  798. "field_close_on_enter[worldedit_gui_cube_height;false]" ..
  799. "field_close_on_enter[worldedit_gui_cube_length;false]" ..
  800. "button_exit[0,3.5;3,0.8;worldedit_gui_cube_submit_hollow;Hollow Cuboid]" ..
  801. "button_exit[3.5,3.5;3,0.8;worldedit_gui_cube_submit_solid;Solid Cuboid]"
  802. end,
  803. })
  804. worldedit.register_gui_handler("worldedit_gui_cube", function(name, fields)
  805. local cg = {
  806. worldedit_gui_cube_search = true,
  807. worldedit_gui_cube_node = gui_nodename1,
  808. worldedit_gui_cube_width = gui_distance1,
  809. worldedit_gui_cube_height = gui_distance2,
  810. worldedit_gui_cube_length = gui_distance3,
  811. }
  812. local ret = handle_changes(name, "worldedit_gui_cube", fields, cg)
  813. if fields.worldedit_gui_cube_submit_hollow or fields.worldedit_gui_cube_submit_solid then
  814. copy_changes(name, fields, cg)
  815. worldedit.show_page(name, "worldedit_gui_cube")
  816. local submit = "hollowcube"
  817. if fields.worldedit_gui_cube_submit_solid then
  818. submit = "cube"
  819. end
  820. local n = worldedit.normalize_nodename(gui_nodename1[name])
  821. if n then
  822. local args = string.format("%s %s %s %s", gui_distance1[name], gui_distance2[name], gui_distance3[name], n)
  823. execute_worldedit_command(submit, name, args)
  824. end
  825. return true
  826. end
  827. return ret
  828. end)
  829. worldedit.register_gui_function("worldedit_gui_clearobjects", {
  830. name = "Clear Objects",
  831. privs = we_privs("clearobjects"),
  832. on_select = function(name)
  833. execute_worldedit_command("clearobjects", name, "")
  834. end,
  835. })