minecraft turtle pastebin command -- 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) minecraft turtle pastebin command How to get it? minecraft turtle pastebin command 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) minecraft turtle pastebin command How to use it? minecraft turtle pastebin command else term.write(curMessage) end end function turnRight(n) n = n or 1 while n > 0 do n = n - 1 facing = (facing + 1) % 4 minecraft turtle pastebin command How to get it for free? minecraft turtle pastebin command turtle.turnRight() end end function turnLeft(n) n = n or 1 while n > 0 do n = n - 1 facing = (facing - 1) % 4 minecraft turtle pastebin command How to dowload it? minecraft turtle pastebin command turtle.turnLeft() end end function right(n) n = n or 1 checkFuel(n) if facing == 0 then turnRight() minecraft turtle pastebin command How to use it? minecraft turtle pastebin command 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 minecraft turtle pastebin command How to get it for free? minecraft turtle pastebin command 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 minecraft turtle pastebin command PasteShr minecraft turtle pastebin command end else while n > 0 do if turtle.back() then n = n - 1 pos[1] = pos[1] + 1 end end end end minecraft turtle pastebin command PasteShr minecraft turtle pastebin command 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 minecraft turtle pastebin command PasteShr minecraft turtle pastebin command 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 minecraft turtle pastebin command PasteShr minecraft turtle pastebin command 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 minecraft turtle pastebin command How to get it for free? minecraft turtle pastebin command if turtle.forward() then n = n - 1 pos[1] = pos[1] - 1 end end end end function forward(n) n = n or 1 minecraft turtle pastebin command How to get it for free? minecraft turtle pastebin command 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 minecraft turtle pastebin command How to dowload it? minecraft turtle pastebin command 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 minecraft turtle pastebin command How to get it for free? minecraft turtle pastebin command 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 minecraft turtle pastebin command How to get it? minecraft turtle pastebin command end end end end function backward(n) n = n or 1 checkFuel(n) if facing == 0 then minecraft turtle pastebin command How to dowload it? minecraft turtle pastebin command 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 minecraft turtle pastebin command How to get it for free? minecraft turtle pastebin command 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 minecraft turtle pastebin command How to get it? minecraft turtle pastebin command end else turnLeft() while n > 0 do if turtle.forward() then n = n - 1 pos[2] = pos[2] - 1 end end end minecraft turtle pastebin command How to get it for free? minecraft turtle pastebin command 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 minecraft turtle pastebin command How to get it? minecraft turtle pastebin command end end end function down(n) n = n or 1 checkFuel(n) while n > 0 do if turtle.down() then minecraft turtle pastebin command PasteShr minecraft turtle pastebin command 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 minecraft turtle pastebin command PasteShr minecraft turtle pastebin command 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]) minecraft turtle pastebin command How to get it? minecraft turtle pastebin command 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 minecraft turtle pastebin command PasteShr minecraft turtle pastebin command tWrite('Refueling...') turtle.select(16) while turtle.getFuelLevel() < n do turtle.refuel(1) end tWrite() end end minecraft turtle pastebin command How to use it? minecraft turtle pastebin command function startingPoint(row) return (2 * (row-1)) % 5 + 1 end function ascend() curMessage = 'Ascending...' tWrite() while pos[3] < 0 do minecraft turtle pastebin command PasteShr minecraft turtle pastebin command if turtle.detectUp() then turtle.digUp() end up() end turtle.select(15) turtle.placeDown() tWrite() end minecraft turtle pastebin command How to get it? minecraft turtle pastebin command 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 minecraft turtle pastebin command PasteShr minecraft turtle pastebin command 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() minecraft turtle pastebin command How to use it? minecraft turtle pastebin command drillSides() end ascend() tWrite() end function drillRow(row) getTo({row, startingPoint(row)}) minecraft turtle pastebin command How to dowload it? minecraft turtle pastebin command local willMove = 0 while (pos[2] + willMove) <= (MaxForward - 2) do emptyInventory() if willMove == 0 then willMove = 5 else forward(willMove) end minecraft turtle pastebin command How to use it? minecraft turtle pastebin command if SkipHoles == 0 then drill() else SkipHoles = SkipHoles - 1 end end end function emptyInventory() curMessage = 'Emptying inventory...' tWrite() minecraft turtle pastebin command PasteShr minecraft turtle pastebin command 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() minecraft turtle pastebin command How to get it? minecraft turtle pastebin command end getTo(curPos) tWrite() end tWrite('Initializing...') for i = 1, MaxRight - 2, 1 do minecraft turtle pastebin command How to get it for free? minecraft turtle pastebin command drillRow(i) end tWrite('Ended') minecraft turtle pastebin command