summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2012-09-25 17:04:24 -0400
committerAnthony Zhang <azhang9@gmail.com>2012-09-25 17:04:24 -0400
commitd89fded397184bebe333ceec0f6f48bb7c55378b (patch)
tree93accc231eb5079844875882ec15b3bdf1045224
parent724cd6ccb633fcc55d0210b282cb7bd696329412 (diff)
Fix negative cylinder lengths (thanks @cornernote).
-rw-r--r--functions.lua14
1 files 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