ComputerCraft 采矿龟不会停止向下挖掘

ComputerCraft mining turtle doesn't stop diging down

我的 mining turtle 代码有问题。 这是我的代码

function mine ()
    done = false

    while not done do
        print("Moving to desired starting height...")

        while not (TURTLE_POSITION.y == heightToStart) do
            turtle.digDown()
            turtle.down()
        end

        print("Starting height reached. Filtering Items...")

        filterItems()

        print("Filtered Items. Starting to mine cuboid...")

        done = true
    end
end

问题是乌龟无论如何都会往下挖。直到到达基岩层才会停止。

编辑:TURTLE_POSITION

的代码
function locateTurtle ()
    print("Attempting to get location")
    location = vector.new(gps.locate(5))

    if not location.x then
        print("Couldn't get location")
        error()
    end

    print("Found location")

    return location
end

refuelTurtle(calculateFuelUsage(cuboidX, cuboidY, cuboidZ))

本地 TURTLE_POSITION = locateTurtle()

根据我收到的评论,这是一个简单的问题:我忘记更新海龟的位置变量

我现在的代码

function mine ()
    done = false

    while not done do
        print("Moving to desired starting height...")

        while not (TURTLE_POSITION.y == heightToStart) do
            turtle.digDown()
            turtle.down()
            TURTLE_POSITION = locateTurtle()
        end

        print("Starting height reached. Filtering Items...")

        filterItems()

        print("Filtered Items. Starting to mine cuboid...")

        done = true
    end
end

function locateTurtle ()
    print("Attempting to get location")
    location = vector.new(gps.locate(5))

    if not location.x then
        print("Couldn't get location")
        error()
    end

    print("Found location")

    return location
end