os.loadAPI('/fuel') function refreshInventory() turtle.down() turtle.down() local current = 3 while (current < 16) do turtle.select(current) turtle.dropDown() current = current + 1 end turtle.select(1) turtle.suckDown(4) --Get new sapling turtle.up() turtle.up() end function isTree() turtle.select(2) return turtle.compare() end function chopTree() local dist = 0 --get in the tree to make sure we do this efficiently turtle.dig() turtle.forward() --clear most of the tree while (turtle.detect() and dist < 60) do turtle.dig() turtle.turnRight() turtle.dig() if (turtle.detectUp()) then turtle.digUp() end turtle.up() turtle.turnLeft() dist = dist + 1 end --position for the last column on the way down turtle.turnRight() turtle.forward() turtle.turnLeft() --clear the last column as we go down the tree while (dist > 0) do dist = dist - 1 turtle.dig() turtle.down() end turtle.dig() --reset turtle to initial position turtle.turnLeft() turtle.turnLeft() turtle.forward() turtle.turnRight() turtle.forward() turtle.turnRight() end function plantTree() turtle.forward() turtle.forward() turtle.turnRight() turtle.place() --back right turtle.turnRight() turtle.forward() turtle.turnLeft() turtle.place() --front right turtle.turnLeft() turtle.place() --back left turtle.turnLeft() turtle.turnLeft() turtle.forward() turtle.turnRight() turtle.turnRight() turtle.place() --front left end local canRefuel = true while (true) do while (turtle.getFuelLevel() < 400) then if (fuel.canRefuel()) then fuel.fuelUp() else print('Cannot refuel') canRefuel = false break end end if (not canRefuel) then break end if (isTree()) then chopTree() refreshInventory() plantTree() end sleep(30) end