1
1
-- saved state for each player
2
- local gui_nodename1 = {}
3
- local gui_nodename2 = {}
4
- local gui_radius = {}
5
- local gui_axis = {}
6
- local gui_length = {}
7
- local gui_formspec = {}
2
+ local gui_nodename1 = {} -- mapping of player names to node names (arbitrary strings may also appear as values)
3
+ local gui_nodename2 = {} -- mapping of player names to node names (arbitrary strings may also appear as values)
4
+ local gui_radius = {} -- mapping of player names to radii (arbitrary strings may also appear as values)
5
+ local gui_axis = {} -- 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_length = {} -- mapping of player names to lengths (arbitrary strings may also appear as values)
7
+ local gui_formspec = {} -- mapping of player names to formspecs (arbitrary strings may also appear as values)
8
+
9
+ local axis_indices = {[" X axis" ]= 1 , [" Y axis" ]= 2 , [" Z axis" ]= 3 , [" Look direction" ]= 4 }
10
+ local axis_values = {" x" , " y" , " z" , " ?" }
8
11
9
12
local register_gui_chatcommand = function (identifier , name , command , callback )
10
13
callback = callback or function (name , command ) command (name , " " ) end
@@ -222,9 +225,6 @@ worldedit.register_gui_function("worldedit_gui_cylinder", {
222
225
end ,
223
226
})
224
227
225
- local axis_indices = {[" X axis" ]= 1 , [" Y axis" ]= 2 , [" Z axis" ]= 3 , [" Look direction" ]= 4 }
226
- local axis_values = {" x" , " y" , " z" , " ?" }
227
-
228
228
worldedit .register_gui_handler (" worldedit_gui_cylinder" , function (name , fields )
229
229
if fields .worldedit_gui_cylinder_search then
230
230
gui_nodename1 [name ] = fields .worldedit_gui_cylinder_node
@@ -246,6 +246,34 @@ worldedit.register_gui_handler("worldedit_gui_cylinder", function(name, fields)
246
246
return false
247
247
end )
248
248
249
+ worldedit .register_gui_function (" worldedit_gui_copy_move" , {
250
+ name = " Copy/Move" , privs = minetest .chatcommands [" /move" ].privs ,
251
+ get_formspec = function (name )
252
+ local axis = gui_axis [name ] or 4
253
+ local amount = gui_length [name ] or " 10"
254
+ return " size[6.5,3]" .. worldedit .get_formspec_header (" worldedit_gui_copy_move" ) ..
255
+ string.format (" field[0.5,1.5;4,0.8;worldedit_gui_copy_move_amount;Amount;%s]" , minetest .formspec_escape (amount )) ..
256
+ string.format (" dropdown[4,1.18;2.5;worldedit_gui_copy_move_axis;X axis,Y axis,Z axis,Look direction;%d]" , axis ) ..
257
+ " button_exit[0,2.5;3,0.8;worldedit_gui_copy_move_copy;Copy Region]" ..
258
+ " button_exit[3.5,2.5;3,0.8;worldedit_gui_copy_move_move;Move Region]"
259
+ end ,
260
+ })
261
+
262
+ worldedit .register_gui_handler (" worldedit_gui_copy_move" , function (name , fields )
263
+ if fields .worldedit_gui_copy_move_copy or fields .worldedit_gui_copy_move_move then
264
+ gui_axis [name ] = axis_indices [fields .worldedit_gui_cylinder_axis ] or 4
265
+ gui_length [name ] = tostring (fields .worldedit_gui_copy_move_amount )
266
+ worldedit .show_page (name , " worldedit_gui_copy_move" )
267
+ if fields .worldedit_gui_copy_move_copy then
268
+ minetest .chatcommands [" /copy" ].func (name , string.format (" %s %s" , axis_values [gui_axis [name ]], gui_length [name ]))
269
+ else -- fields.worldedit_gui_copy_move_move
270
+ minetest .chatcommands [" /move" ].func (name , string.format (" %s %s" , axis_values [gui_axis [name ]], gui_length [name ]))
271
+ end
272
+ return true
273
+ end
274
+ return false
275
+ end )
276
+
249
277
worldedit .register_gui_function (" worldedit_gui_formspec_tester" , {
250
278
name = " Formspec Tester" ,
251
279
get_formspec = function (name )
0 commit comments