Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = nil
- y = nil
- z = 0
- slot = 1
- function selectSlot()
- if turtle.getItemCount(slot) == 0 and slot < 16 then
- slot = slot + 1
- elseif turtle.getItemCount(slot) == 0 and slot == 16 then
- slot = 1
- end
- turtle.select(slot)
- end
- function digHole()
- while z < h do
- turtle.digDown()
- turtle.down()
- z = z + 1
- end
- while z > 0 do
- turtle.digUp()
- turtle.up()
- z = z - 1
- end
- end
- function testRange()
- if math.sqrt(math.pow(x, 2) + math.pow(y, 2)) <= r then
- return true
- else
- return false
- end
- end
- function testRangeInverse()
- if math.sqrt(math.pow(x, 2) + math.pow(y, 2)) >= r-1 then
- return true
- else
- return false
- end
- end
- function subSearch()
- while y <= r do
- if testRange() then
- digHole()
- end
- while x < r do
- turtle.dig()
- turtle.forward()
- x = x + 1
- if testRange() then
- digHole()
- end
- end
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- y = y + 1
- if testRange() then
- digHole()
- end
- turtle.turnRight()
- while x > -r do
- turtle.dig()
- turtle.forward()
- x = x - 1
- if testRange() then
- digHole()
- end
- end
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- y = y + 1
- if testRange() then
- digHole()
- end
- turtle.turnLeft()
- end
- end
- function addSearch()
- while y <= r do
- if testRange() and testRangeInverse() then
- turtle.digDown()
- selectSlot()
- turtle.placeDown()
- end
- while x < r do
- turtle.dig()
- turtle.forward()
- x = x + 1
- if testRange() then
- turtle.digDown()
- selectSlot()
- turtle.placeDown()
- end
- end
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- y = y + 1
- if testRange() then
- turtle.digDown()
- selectSlot()
- turtle.placeDown()
- end
- turtle.turnRight()
- while x > -r do
- turtle.dig()
- turtle.forward()
- x = x - 1
- if testRange() then
- turtle.digDown()
- selectSlot()
- turtle.placeDown()
- end
- end
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- y = y + 1
- if testRange() then
- turtle.digDown()
- selectSlot()
- turtle.placeDown()
- end
- turtle.turnLeft()
- end
- end
- print("+-------------------------------------+")
- print("| Circle Miner |")
- print("+-------------------------------------+")
- print("+-------------------------------------+")
- print("+-------------------------------------+")
- read()
- print("+-------------------------------------+")
- print("| Radius = ? |")
- print("+-------------------------------------+")
- r = tonumber(read())
- print("+-------------------------------------+")
- print("| Mode = ? |")
- print("+-------------------------------------+")
- mode = tostring(read())
- x = -r
- y = -r
- if mode == "sub" then
- print("+-------------------------------------+")
- print("| Height = ? |")
- print("+-------------------------------------+")
- h = tonumber(read())
- subSearch()
- end
- if mode == "add" then
- addSearch()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement