Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function distSq(x, y, z)
- return x * x + y * y + z * z
- end
- local function build()
- while turtle.getItemCount(1) <= 1 do
- if not supply.resupply(1) then
- os.sleep(10)
- end
- end
- turtle.placeDown()
- end
- local quarters = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 0}}
- os.loadAPI("utils")
- supply = peripheral.wrap("right")
- args = {...}
- if #args < 1 then os.exit() end
- radius = args[1] + 0
- rmax = (radius + .5) * (radius + .5)
- rmin = (radius - .5) * (radius - .5)
- for height = turtle.y, radius do
- utils.goto(turtle.x, height, turtle.z)
- for i = 1, 4 do
- local max = radius
- for over = 0, radius do
- out = max
- while (out > 0) and distSq(out, height, over) >= rmax do
- out = out - 1
- end
- max = out
- while (out > 0) and distSq(out, height, over) > rmin do
- utils.goto(quarters[i][1] * out +
- quarters[i+1][1] * over,
- height,
- quarters[i][2] * out +
- quarters[i+1][2] * over)
- build()
- out = out - 1
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement