Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if #args < 2 then return end
- os.loadAPI("utils")
- local maxX, maxZ = 0 + args[1], 0 + args[2]
- local count
- local curX, curZ = turtle.x, turtle.z
- local curY = turtle.y
- for i = 1,16 do
- if turtle.getItemCount(i) == 0 then
- count = i - 1
- break
- end
- end
- local function suck()
- while turtle.suck() do end
- turtle.dig()
- end
- local function suckDown()
- while turtle.suckDown() do end
- turtle.digDown()
- end
- local function suckUp()
- while turtle.suckUp() do end
- turtle.digUp()
- end
- local function matches(func)
- if not count then return false end
- for i = 1, count do
- turtle.select(i)
- if func() then return true end
- end
- return false
- end
- local function tunnel(x)
- local func, func2, func3
- for j = 1, 2 do
- if j == 1 then
- func = turtle.compareUp
- func2 = suckUp
- else
- func = turtle.compareDown
- func2 = suckDown
- end
- for i = 1, x do
- turtle.select(count + 1)
- turtle.turnLeft()
- if not matches(turtle.compare) then
- suck()
- end
- turtle.turnRight()
- turtle.turnRight()
- if not matches(turtle.compare) then
- suck()
- end
- turtle.turnLeft()
- if not matches(func) then
- func2()
- end
- if i ~= x then
- suck()
- if not utils.forward() then return false end
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- if j == 1 then
- turtle.digDown()
- turtle.down()
- else
- turtle.digUp()
- turtle.up()
- end
- end
- return true
- end
- while true do
- for z = curY % 4, maxZ - 1, 4 do
- while turtle.getFuelLevel() < 2 * (maxZ + maxZ - curY + 25) do
- os.sleep(1)
- end
- if not utils.goto(0, curY, z) then
- utils.goto(0, 0, 0)
- return
- end
- turtle.rotate(1, 0)
- if not tunnel(maxX) then return end
- utils.goto(0, 0, 0)
- turtle.rotate(-1, 0)
- for i = count + 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- curY = curY - 2
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement