Uberi/MineTest-WorldEdit — pull request #20 by khonkhortisan (2012-10-19 05:46:20+00:00)
Title: //cylinder <axis> <length> <radius1> [<radius2>] <node>

This is a response to #2.

If there were both`//cylinder` and `//cone` commands, we would be able to make cylinders and cones. But by adding a second base to the cylinder, one can make shapes between cylinders and cones.

**Behavior:**
To make a cylinder, use a single radius: `//cylinder y 20 10 dirt` (default behavior)
To make a cone, use a second radius of zero: `//cylinder y 20 10 0 dirt`
To make a conical cylinder/half-cut cone, use different-sized radii: `//cylinder y 20 5 10 dirt`

![gif animation](http://s16.postimage.org/rnlchfe0h/Conical_Cylinder.gif)

**Note:** Because `diameter = radius + 1 + radius` (also default behavior), to have a "perfect" cone with a 1:1 slope, *\* would be one more than *\*: `//cylinder y 6 5 0 dirt`

**Complaint:** I found four places I had to edit to change the description of this command: Chat Commands.md, WorldEdit API.md, worldedit/primitives.lua, and worldedit_commands/init.lua. I expected two places at the most.

**Fun:** Run `//cylinder y 20 0 20 air` from 20 below the surface of the ocean! You'll get a (temporary) whirlpool!

**Issue:**
To make the radius go between the two bases, I used this line.
`local radius = radius1 + (radius2 - radius1) * (i - 1) / (length - 1)`
Depending on what *\*, *\*, and *\* you give it, sometimes it will have a decimal radius that loop.

The rest of the function doesn't seem to be able to handle a non-int radius. Without rounding the radius, the cone will either
• either be lopsided to one side of both the x and z axes,
• or have tunnels going through it,
• and it will return a decimal node count.

Therefore, as a cop-out, I added this line.
`radius = math.floor(radius+0.5)`
It rounds the radius, creating an obvious ring around the cone when the radius jumps, instead of smoothly increasing in smaller-than-1 increments. This could be fixed, along with the count returned when the radius isn't rounded.

So if this pull request was merged, an issue would come with it, to have it work without having to round the radius.

**Name:** I considered changing the name of the command, but I couldn't think of a single word that would give the idea that it could be a cylinder or a cone or anywhere in between. So I'll just geometrically assume a cone is a cylinder with a base of zero.