Skip to main content

forceForward

local searchedBlock = "minecraft:oak_log"


function forceForward()
    turtle.dig()
    turtle.forward()
end


function forceBack()
    turtle.back()
end

function forceUp()
    turtle.digUp()
    turtle.up()
end


function forceDown()
    turtle.digDown()
    turtle.down()
end


function makeNewFuel()
    turtle.turnLeft()
    turtle.forward()
    turtle.forward()
    turtle.up()
    turtle.forward()
    turtle.select(2)
    turtle.dropDown(3)
    turtle.turnRight()
    turtle.forward()
    turtle.down()
    turtle.down()
    turtle.down()
    turtle.turnLeft()
    turtle.turnLeft()
    turtle.forward()
    turtle.dropUp(2)
    turtle.turnRight()
    turtle.turnRight()
    turtle.forward()
    turtle.up()
    turtle.turnRight()
   
    turtle.turnRight()
    os.sleep(30)
    turtle.select(16)
    turtle.suck(3)
    turtle.select(15)
    turtle.suck(3)
    turtle.turnLeft()
   
    turtle.forward()
    turtle.turnRight()
    turtle.forward()
    turtle.turnRight()
   
    turtle.turnRight()
    turtle.turnRight()
    turtle.forward()
    turtle.forward()
    turtle.turnLeft()
end


function checkFuel()
    local fuelLevel = turtle.getFuelLevel()
    if fuelLevel < 50 then
        turtle.select(16)
        turtle.refuel(1)
        print("Neu betankt!")
    end
    turtle.select(16)
    if turtle.getItemCount(16) < 10 then
        makeNewFuel()
    end
end


function searchForTreeFront()
    success, data = turtle.inspect()
    if success and data.name == searchedBlock then
        forceForward()
        searchForTreeUp()
        forceBack()
    end
end


function searchForTreeUp()
    success, data = turtle.inspectUp()
    if success and data.name == searchedBlock then
        forceUp()
        searchForTreeUp()
        forceDown()
    end
end


function searchForTree()
    searchForTreeFront()
end


function plantSapling()
    turtle.select(1)
    turtle.place()
end


local chopping = true


while chopping do
    checkFuel()
    searchForTree()
    plantSapling()
end