Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local radius = { tonumber( tArgs[1] ), tonumber(tArgs[1])^2 }
- local radians = tonumber( tArgs[2] )
- local fill = tArgs[3]
- local xPos, zPos = radius[1],0
- local xDir, zDir = -1,0
- if radians == 2 then
- xPos, zPos = radius[1], radius[1]
- xDir, zDir = -1,0
- elseif radians == 1 then
- xPos, zPos = radius[1], 0
- xDir, zDir = -1,0
- end
- local circle = {}
- for i = -radius[1], radius[1], 1 do
- circle[i] = {}
- for j = -radius[1], radius[1], 1 do
- circle[i][j] = 0
- end
- end
- local z = radius[1]
- for x = 0, radius[1], 1 do
- if math.abs((z^2 + x^2)^0.5 - radius[1]) > math.abs(((z-1)^2 + x^2)^0.5 - radius[1]) then
- z = z-1
- end
- if z < x then
- break
- end
- circle[x][z] = 1
- circle[z][x] = 1
- circle[x][-z] = 1
- circle[z][-x] = 1
- circle[-x][z] = 1
- circle[-z][x] = 1
- circle[-x][-z] = 1
- circle[-z][-x] = 1
- end
- for x = 0, radius[1] - 1, 1 do
- for z = 0, radius[1] - 1, 1 do
- if circle[x][z] == 1 then
- break
- end
- circle[x][z] = 2
- circle[x][-z] = 2
- circle[-x][z] = 2
- circle[-x][-z] = 2
- end
- end
- local done = false
- local curSlot = 1
- local function selectResource()
- while turtle.getItemCount(curSlot) == 0 do
- curSlot = curSlot + 1
- if curSlot > 16 then
- return false
- end
- end
- turtle.select(curSlot)
- end
- local function place()
- selectResource()
- turtle.place()
- end
- local function placeUp()
- selectResource()
- turtle.placeUp()
- end
- local function placeDown()
- selectResource()
- turtle.placeDown()
- end
- local function move()
- if xPos == -radius[1] and math.abs(xDir+xPos) > radius[1] then
- if zPos == radius[1] then
- done = true
- else
- turtle.turnRight()
- if turtle.forward() then
- zPos = zPos + 1
- end
- turtle.turnRight()
- xDir = 1
- end
- elseif xPos == radius[1] and math.abs(xDir+xPos) > radius[1] then
- if zPos == radius[1] then
- done = true
- else
- turtle.turnLeft()
- if turtle.forward() then
- zPos = zPos + 1
- end
- turtle.turnLeft()
- xDir = -1
- end
- else
- if turtle.forward() then
- xPos = xDir + xPos
- end
- end
- end
- while not done do
- if circle[xPos][zPos] == 1 or (circle[xPos][zPos] == 2 and fill) then
- placeDown()
- print("(" .. xPos .. ", " .. zPos .. ") -> " .. circle[xPos][zPos])
- end
- move()
- end
Advertisement
Add Comment
Please, Sign In to add comment