minig turle commands -- Turtle inventory should be 4 by 4 -- A chest or an inventory should be present at the left of the starting position -- The block layer at the turtle's level should be clear, fully digged for the defined mining zone -- Fuel should be on the lower right slot -- Any well-sealing block should be on slot 15, left of the fuel -- Blocks not to be mined should be on the first line -- Define the mining zone here MaxForward = 16 MaxRight = 16 -- Number of holes to skip (beginning) minig turle commands How to dowload it? minig turle commands SkipHoles = 0 local pos = {0, 0, 0} local facing = 0 local curMessage = '' function tWrite(txt) term.clear() term.setCursorPos(1, 1) if txt then term.write(txt) minig turle commands PasteShr minig turle commands else term.write(curMessage) end end function turnRight(n) n = n or 1 while n > 0 do n = n - 1 facing = (facing + 1) % 4 minig turle commands How to get it for free? minig turle commands turtle.turnRight() end end function turnLeft(n) n = n or 1 while n > 0 do n = n - 1 facing = (facing - 1) % 4 minig turle commands PasteShr minig turle commands turtle.turnLeft() end end function right(n) n = n or 1 checkFuel(n) if facing == 0 then turnRight() minig turle commands How to get it? minig turle commands while n > 0 do if turtle.forward() then n = n - 1 pos[1] = pos[1] + 1 end end elseif facing == 1 then while n > 0 do if turtle.forward() then n = n - 1 minig turle commands How to get it for free? minig turle commands pos[1] = pos[1] + 1 end end elseif facing == 2 then turnLeft() while n > 0 do if turtle.forward() then n = n - 1 pos[1] = pos[1] + 1 end minig turle commands How to use it? minig turle commands end else while n > 0 do if turtle.back() then n = n - 1 pos[1] = pos[1] + 1 end end end end minig turle commands How to get it? minig turle commands function left(n) n = n or 1 checkFuel(n) if facing == 0 then turnLeft() while n > 0 do if turtle.forward() then n = n - 1 minig turle commands How to get it? minig turle commands pos[1] = pos[1] - 1 end end elseif facing == 1 then while n > 0 do if turtle.back() then n = n - 1 pos[1] = pos[1] - 1 end end minig turle commands How to dowload it? minig turle commands elseif facing == 2 then turnRight() while n > 0 do if turtle.forward() then n = n - 1 pos[1] = pos[1] - 1 end end else while n > 0 do minig turle commands How to dowload it? minig turle commands if turtle.forward() then n = n - 1 pos[1] = pos[1] - 1 end end end end function forward(n) n = n or 1 minig turle commands How to get it for free? minig turle commands checkFuel(n) if facing == 0 then while n > 0 do if turtle.forward() then n = n - 1 pos[2] = pos[2] + 1 end end elseif facing == 1 then minig turle commands How to get it for free? minig turle commands turnLeft() while n > 0 do if turtle.forward() then n = n - 1 pos[2] = pos[2] + 1 end end elseif facing == 2 then while n > 0 do if turtle.back() then minig turle commands How to use it? minig turle commands n = n - 1 pos[2] = pos[2] + 1 end end else turnRight() while n > 0 do if turtle.forward() then n = n - 1 pos[2] = pos[2] + 1 minig turle commands How to dowload it? minig turle commands end end end end function backward(n) n = n or 1 checkFuel(n) if facing == 0 then minig turle commands How to use it? minig turle commands while n > 0 do if turtle.back() then n = n - 1 pos[2] = pos[2] - 1 end end elseif facing == 1 then turnRight() while n > 0 do if turtle.forward() then minig turle commands How to get it for free? minig turle commands n = n - 1 pos[2] = pos[2] - 1 end end elseif facing == 2 then while n > 0 do if turtle.forward() then n = n - 1 pos[2] = pos[2] - 1 end minig turle commands How to use it? minig turle commands end else turnLeft() while n > 0 do if turtle.forward() then n = n - 1 pos[2] = pos[2] - 1 end end end minig turle commands How to dowload it? minig turle commands end function up(n) n = n or 1 checkFuel(n) while n > 0 do if turtle.up() then n = n - 1 pos[3] = pos[3] + 1 minig turle commands How to get it for free? minig turle commands end end end function down(n) n = n or 1 checkFuel(n) while n > 0 do if turtle.down() then minig turle commands How to get it for free? minig turle commands n = n - 1 pos[3] = pos[3] - 1 end end end function getTo(nPos) if not nPos[1] then nPos[1] = pos[1] end if not nPos[2] then nPos[2] = pos[2] end if not nPos[3] then nPos[3] = pos[3] end minig turle commands How to get it for free? minig turle commands diff = {nPos[1] - pos[1], nPos[2] - pos[2], nPos[3] - pos[3]} -- Right / left if diff[1] > 0 then right(diff[1]) elseif diff[1] < 0 then left(-diff[1]) end -- Forward / backward if diff[2] > 0 then forward(diff[2]) elseif diff[2] < 0 then backward(-diff[2]) minig turle commands How to dowload it? minig turle commands end -- Up / down if diff[3] > 0 then up(diff[3]) elseif diff[3] < 0 then down(-diff[3]) end end function checkFuel(n) if turtle.getFuelLevel() < n then minig turle commands How to use it? minig turle commands tWrite('Refueling...') turtle.select(16) while turtle.getFuelLevel() < n do turtle.refuel(1) end tWrite() end end minig turle commands How to use it? minig turle commands function startingPoint(row) return (2 * (row-1)) % 5 + 1 end function ascend() curMessage = 'Ascending...' tWrite() while pos[3] < 0 do minig turle commands How to dowload it? minig turle commands if turtle.detectUp() then turtle.digUp() end up() end turtle.select(15) turtle.placeDown() tWrite() end minig turle commands How to get it? minig turle commands function drillSides() for i = 0, 3, 1 do local canDig = true for j = 1, 4, 1 do turtle.select(j) if turtle.compare() then canDig = false end end if canDig then turtle.dig() end minig turle commands How to use it? minig turle commands if i ~=3 then turnLeft() end end end function drill() curMessage = 'Drilling...' tWrite() while (not turtle.detectDown()) or (turtle.detectDown() and turtle.digDown()) do down() minig turle commands How to dowload it? minig turle commands drillSides() end ascend() tWrite() end function drillRow(row) getTo({row, startingPoint(row)}) minig turle commands How to dowload it? minig turle commands local willMove = 0 while (pos[2] + willMove) <= (MaxForward - 2) do emptyInventory() if willMove == 0 then willMove = 5 else forward(willMove) end minig turle commands PasteShr minig turle commands if SkipHoles == 0 then drill() else SkipHoles = SkipHoles - 1 end end end function emptyInventory() curMessage = 'Emptying inventory...' tWrite() minig turle commands PasteShr minig turle commands local curPos = {pos[1], pos[2]} getTo({0,0}) while facing ~= 3 do turnRight() end for i = 5, 14, 1 do turtle.select(i) turtle.drop() minig turle commands How to get it? minig turle commands end getTo(curPos) tWrite() end tWrite('Initializing...') for i = 1, MaxRight - 2, 1 do minig turle commands How to use it? minig turle commands drillRow(i) end tWrite('Ended') minig turle commands