os.loadAPI('/fuel') local args = { ... } if #args < 2 or #args > 3 then print( "Usage: quarry [ ]" ) error() end function checkFuel() while (turtle.getFuelLevel() < 100) do if (fuel.canRefuel()) then fuel.fuelUp() else return false end end return true end function fullInventory() local full = true local current = 1 while (current < 16) do if (turtle.getItemCount(current) == 0) then full = false end current = current + 1 end return full end function dropEverything() local current = 1 while (current < 16) do turtle.dropDown() current = current + 1 end end function digLength() local forward = 0 while (forward < tonumber(args[2])) do if (not checkFuel()) then return false end if (turtle.detect()) then turtle.dig() end turtle.forward() forward = forward + 1 if (fullInventory()) then dropEverything() end end return true end local canRefuel = true local depth = 0 while (true) do if (not digLength()) then return end local right = 0 while (right < tonumber(args[1])) do turtle.turnRight() if (turtle.detect()) then turtle.dig() end turtle.forward() turtle.turnRight() if (not digLength()) then return end turtle.turnLeft() if (turtle.detect()) then turtle.dig() end turtle.forward() turtle.turnLeft() if (not digLength()) then return end right = right + 2 end if (#args > 2) then if (depth >= tonumber(args[3])) then print('Mining Complete') return end end turtle.turnRight() turtle.turnRight() if (turtle.detectDown()) then if (not turtle.digDown()) then print ('Reached the bottom') return end end turtle.down() depth = depth + 1 print('Dug ' .. depth .. ' layers') end