Support spiral

This commit is contained in:
Hybrid Dog 2018-02-02 14:04:21 +01:00
parent 101523e1e9
commit 48553a1cdc
2 changed files with 29 additions and 1 deletions

@ -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

@ -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)