From 48553a1cdcc005bf8376361cc77d268313695baa Mon Sep 17 00:00:00 2001 From: Hybrid Dog Date: Fri, 2 Feb 2018 14:04:21 +0100 Subject: [PATCH] Support spiral --- README.md | 3 ++- init.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 51adc23..2a14c9c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Supported chatcommands: * /hollowcylinder and /hcyl * /pyramid and /pyr * /hollowpyramid and /hpyr +* /spiral * /load * /y * /n @@ -50,7 +51,6 @@ Not yet implemented: * /contract * /outset * /inset -* /spiral * /copy * /move * /stack @@ -78,3 +78,4 @@ TODO: * Add times to the changes, show in //show_journal * Implement more commands * worldedit pyramid fix +* Fix the shown "nodes changed" count diff --git a/init.lua b/init.lua index 550c3fd..b318087 100644 --- a/init.lua +++ b/init.lua @@ -18,6 +18,7 @@ local command_invoker local function override_chatcommand(cname, func_before, func_after) local command = minetest.registered_chatcommands[cname] + assert(command, "Chatcommand " .. cname .. " isn't registered.") -- save the name of the player and execute func_before if present if func_before then local func = command.func @@ -715,6 +716,32 @@ for i = 1,2 do ) end +local we_spiral = worldedit.spiral +local function spiral_func(_,_, ...) + return we_spiral(...) +end +local function my_we_spiral(pos, length, height, spacer, ...) + -- FIXME adding the spacer to the extent makes it work + local extent = math.ceil(length / 2) + spacer + + local pos1 = vector.subtract(pos, extent) + local pos2 = vector.add(pos, extent) + + pos1.y = pos.y + pos2.y = pos.y + math.ceil(height) - 1 + + return we_nodeset_wrapper(spiral_func, pos1, pos2, pos, length, height, + spacer, ...) +end +override_cc_with_confirm("/spiral", + function() + worldedit.spiral = my_we_spiral + end, + function() + worldedit.spiral = we_spiral + end +) + -- tells if the metadata is that dummy local function is_meta_empty(metatabl)