diff --git a/README.md b/README.md index 47126b6..51adc23 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Supported chatcommands: * /hollowdome and /hdo * /cylinder and /cyl * /hollowcylinder and /hcyl +* /pyramid and /pyr +* /hollowpyramid and /hpyr * /load * /y * /n @@ -48,8 +50,6 @@ Not yet implemented: * /contract * /outset * /inset -* /hollowpyramid /hpyr -* /pyramid /pyr * /spiral * /copy * /move @@ -77,3 +77,4 @@ TODO: e.g. //undo ~1 to undo the change before the latest one * Add times to the changes, show in //show_journal * Implement more commands +* worldedit pyramid fix diff --git a/init.lua b/init.lua index d4e117f..550c3fd 100644 --- a/init.lua +++ b/init.lua @@ -681,6 +681,40 @@ for i = 1,2 do ) end +local we_pyramid = worldedit.pyramid +local function pyramid_func(_,_, ...) + return we_pyramid(...) +end +local function my_we_pyramid(pos, axis, height, ...) + local h = math.ceil(math.abs(height)) + -- This code is commented because of a worldedit pyramid wrapping bug. FIXME + --~ local pos1 = vector.subtract(pos, h-1) + --~ local pos2 = vector.add(pos, h-1) + + --~ if height > 0 then + --~ pos1[axis] = pos[axis] + --~ else + --~ pos2[axis] = pos[axis] + --~ end + + -- This workaround doesn't necessarily work right. It worked when tested. + local pos1 = vector.subtract(pos, h + 15) + local pos2 = vector.add(pos, h + 15) + + return we_nodeset_wrapper(pyramid_func, pos1, pos2, pos, axis, height, ...) +end +local pyramid_cmds = {"/pyramid", "/hollowpyramid"} +for i = 1,2 do + override_cc_with_confirm(pyramid_cmds[i], + function() + worldedit.pyramid = my_we_pyramid + end, + function() + worldedit.pyramid = we_pyramid + end + ) +end + -- tells if the metadata is that dummy local function is_meta_empty(metatabl)