plotCornerBL = vector.new(13,0,1) plotCornerTR = vector.new(0,0,13) plotLimitxLeft = 13 plotLimitxRight = 0 plotStrips = { 4, 10 } plotHoverHeight = 1 chestFaceDir = 3 blueWoolFaceDir = 2 woodChestAccessHeight = 0 fuelChestAccessHeight = 1 saplChestAccessHeight = 2 fuelInvSlot = 16 saplingInvSlot = 15 blueWoolIdentifier = "minecraft:blue_wool" cobbleIdentifier = "minecraft:cobblestone" birchLogIdentifier = "minecraft:birch_log" birchSaplIdentifier = "minecraft:birch_sapling" currentPos = nil currentDirection = nil function panic() while true do turtle.turnRight() end end function turnToDir(targetDir) while currentDirection ~= targetDir do turtle.turnRight() currentDirection = currentDirection + 1 if currentDirection == 5 then currentDirection = 1 end end end function moveForward() success = turtle.forward() delta = vector.new(0,0,0) if not success then return success end if currentDirection == 1 then delta = vector.new(0,0,1) elseif currentDirection == 2 then delta = vector.new(-1,0,0) elseif currentDirection == 3 then delta = vector.new(0,0,-1) elseif currentDirection == 4 then delta = vector.new(1,0,0) end currentPos = currentPos + delta turtle.suckDown() return success end function moveUp() success = turtle.up() if success then currentPos = currentPos + vector.new(0,1,0) end return success end function moveDown() success = turtle.down() if success then currentPos = currentPos + vector.new(0,-1,0) end return success end function goToPos(dx,dy,dz,df) while currentPos.y ~= plotHoverHeight do if currentPos.y > plotHoverHeight then moveDown() else moveUp() end end if currentPos.z > dz then turnToDir(3) elseif currentPos.z < dz then turnToDir(1) end while currentPos.z ~= dz do success = moveForward() if not success then blockpres, blockdata = turtle.inspect() if not blockpres then panic() else if blockdata.name == birchLogIdentifier then turtle.dig() end end end end if currentPos.x > dx then turnToDir(2) elseif currentPos.x < dx then turnToDir(4) end while currentPos.x ~= dx do success = moveForward() if not success then blockpres, blockdata = turtle.inspect() if not blockpres then panic() elseif blockdata.name == birchLogIdentifier then turtle.dig() end end end while currentPos.y ~= dy do if currentPos.y > dy then moveDown() else moveUp() end end if df ~= 0 then turnToDir(df) end end function powerOnSelfTest() if turtle.getFuelLevel() < 20 then turtle.select(fuelInvSlot) if not turtle.refuel() then return false -- needs fuel to POST end end while not turtle.detectDown() do turtle.down() end dpres, ddata = turtle.inspectDown() if ddata.name == cobbleIdentifier then while currentDirection == nil do bwpres, bwdata = turtle.inspect() if bwpres then if bwdata.name == blueWoolIdentifier then currentDirection = blueWoolFaceDir else turtle.turnRight() end else turtle.turnRight() end end end currentPos = vector.new(0,0,0) turnToDir(1) print("POST complete, home set.") return true end function dumpInventory() goToPos(0,woodChestAccessHeight,0,chestFaceDir) for i = 1, 16, 1 do turtle.select(i) if turtle.getItemDetail() ~= nil then if turtle.getItemDetail().name == birchLogIdentifier then turtle.drop(turtle.getItemDetail().count) end end end goToPos(0,saplChestAccessHeight,0,chestFaceDir) for i = 1, 14, 1 do turtle.select(i) if turtle.getItemDetail() ~= nil then if turtle.getItemDetail().name == birchSaplIdentifier then if not turtle.transferTo(saplingInvSlot, turtle.getItemDetail().count) then turtle.drop(turtle.getItemDetail().count) end end end end turtle.select(15) if turtle.getItemDetail() ~= nil then if turtle.getItemDetail().count < 64 then turtle.suck(64 - turtle.getItemDetail().count) end else turtle.suck(64) end goToPos(0,fuelChestAccessHeight,0,chestFaceDir) for i = 1, 16, 1 do turtle.select(i) if turtle.getItemDetail() ~= nil then if turtle.getItemDetail().name == "minecraft:stick" then turtle.drop(turtle.getItemDetail().count) end end end end function preCheckFuel(min) goToPos(0,fuelChestAccessHeight,0,chestFaceDir) for i = 1,15,1 do if turtle.getItemDetail() ~= nil then if turtle.getItemDetail().name == "minecraft:charcoal" then turtle.drop(turtle.getItemDetail().count) end end end turtle.select(16) if turtle.getItemDetail() ~= nil then fuelCountNeeded = 64 - turtle.getItemDetail().count else fuelCountNeeded = 64 end turtle.suck(64) turtle.refuel() end function harvestSweep() for i = 1,#plotStrips,1 do goToPos(plotLimitxRight,1,plotStrips[i] - 1,0) goToPos(plotLimitxRight,1,plotStrips[i],4) turtle.dig() moveForward() while currentPos.x < plotLimitxLeft do blockpres, blockdata = turtle.inspectDown() if blockdata.name == birchLogIdentifier then turtle.digUp() moveUp() turtle.digUp() moveUp() turtle.digUp() moveDown() moveDown() turtle.digDown() turtle.select(saplingInvSlot) turtle.placeDown() end turtle.dig() moveForward() end end end function saplingSweep() for iz = plotCornerBL.z,plotCornerTR.z,1 do for ix = plotCornerTR.x,plotCornerBL.x,1 do goToPos(ix,plotHoverHeight,iz,0) turtle.suckDown() end end end if not powerOnSelfTest() then print("POST failed") end while true do preCheckFuel() harvestSweep() sleep() --saplingSweep() dumpInventory() goToPos(0,0,0,1) sleep(1200) end