From d89fded397184bebe333ceec0f6f48bb7c55378b Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Tue, 25 Sep 2012 17:04:24 -0400 Subject: [PATCH] Fix negative cylinder lengths (thanks @cornernote). --- functions.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/functions.lua b/functions.lua index 2d16daf..eaac5d6 100644 --- a/functions.lua +++ b/functions.lua @@ -90,6 +90,11 @@ worldedit.hollow_cylinder = function(pos, axis, length, radius, nodename) local currentpos = {x=pos.x, y=pos.y, z=pos.z} local node = {name=nodename} local count = 0 + local step = 1 + if length < 0 + length = -length + step = -1 + end for i = 1, length do local offset1, offset2 = 0, radius local delta = -radius @@ -126,7 +131,7 @@ worldedit.hollow_cylinder = function(pos, axis, length, radius, nodename) end offset1 = offset1 + 1 end - currentpos[axis] = currentpos[axis] + 1 + currentpos[axis] = currentpos[axis] + step end return count end @@ -146,6 +151,11 @@ worldedit.cylinder = function(pos, axis, length, radius, nodename) local currentpos = {x=pos.x, y=pos.y, z=pos.z} local node = {name=nodename} local count = 0 + local step = 1 + if length < 0 + length = -length + step = -1 + end for i = 1, length do local offset1, offset2 = 0, radius local delta = -radius @@ -180,7 +190,7 @@ worldedit.cylinder = function(pos, axis, length, radius, nodename) delta = delta - (offset2 * 2) end end - currentpos[axis] = currentpos[axis] + 1 + currentpos[axis] = currentpos[axis] + step end return count end