local function checkFuel()
if turtle.getFuelLevel() < 20 then
turtle.select(1)
turtle.refuel(1)
end
end
local function column()
local height = 0
while turtle.digUp() do
turtle.dig()
checkFuel()
turtle.up()
height = height + 1
end
turtle.dig()
checkFuel()
return height
end
local function columnDown(height)
for i=1,height do
checkFuel()
turtle.dig()
turtle.digDown()
turtle.down()
end
turtle.dig()
end
local function digmove()
checkFuel()
turtle.dig()
turtle.forward()
end
local function fell()
digmove()
local height = column()
turtle.turnRight()
digmove()
turtle.turnLeft()
columnDown(height)
end
local function replant()
turtle.select(15)
turtle.suck()
turtle.place()
turtle.turnLeft()
turtle.suck()
turtle.forward()
turtle.suck()
turtle.turnRight()
turtle.suck()
turtle.place()
turtle.turnRight()
turtle.suck()
turtle.place()
turtle.turnRight()
turtle.suck()
turtle.forward()
turtle.suck()
for slot=3,7 do
turtle.select(slot)
turtle.drop()
end
turtle.turnLeft()
turtle.turnLeft()
turtle.select(15)
turtle.place()
turtle.select(2)
while not turtle.compare() do
turtle.select(16)
turtle.place()
turtle.select(2)
end
end
function needCoal()
return turtle.getItemCount(1) < 10
end
function needBonemeal()
return turtle.getItemCount(16) < 10
end
function getCoal()
turtle.turnRight()
turtle.forward()
turtle.forward()
while turtle.getItemCount(1) < 60 do
sleep(0.5)
end
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.turnRight()
end
function getBonemeal()
turtle.turnLeft()
turtle.forward()
while turtle.getItemCount(16) < 60 do
sleep(0.5)
end
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
end
while true do
fell()
replant()
if needCoal() then
getCoal()
end
if needBonemeal() then
getBonemeal()
end
end