Support cube and hollowcube

This commit is contained in:
HybridDog
2021-07-29 14:43:32 +02:00
parent a9af2cbb89
commit 23eb83778c
2 changed files with 25 additions and 1 deletions

View File

@ -16,6 +16,7 @@ Supported chatcommands:
* /mix
* /replace and /r
* /replaceinverse and /ri
* /cube and /hollowcube
* /sphere and /spr
* /hollowsphere and /hspr
* /dome and /do
@ -51,7 +52,6 @@ Not yet implemented:
* /contract
* /outset
* /inset
* /cube /hollowcube
* /copy
* /move
* /stack

View File

@ -602,6 +602,30 @@ for i = 1,2 do
)
end
local we_cube = worldedit.cube
local function cube_func(_,_, ...)
return we_cube(...)
end
local function my_we_cube(pos, w, h, l, ...)
local cw, ch, cl = math.ceil(w), math.ceil(h), math.ceil(l)
local ox = math.ceil((cw-1)/2)
local oz = math.ceil((cl-1)/2)
local pos1 = {x = pos.x - ox, y = pos.y, z = pos.z - oz}
local pos2 = {x = pos.x + ox, y = pos.y + ch - 1, z = pos.z + oz}
return we_nodeset_wrapper(cube_func, pos1, pos2, pos, w, h, l, ...)
end
local cube_cmds = {"/cube", "/hollowcube"}
for i = 1,2 do
override_cc_with_confirm(cube_cmds[i],
function()
worldedit.cube = my_we_cube
end,
function()
worldedit.cube = we_cube
end
)
end
local we_sphere = worldedit.sphere
local function sph_func(_,_, ...)
return we_sphere(...)