首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ComputerCraft矿龟不会停止设计

ComputerCraft矿龟不会停止设计
EN

Stack Overflow用户
提问于 2020-12-09 05:15:09
回答 1查看 121关注 0票数 0

我的挖掘海龟代码有问题。这是我的代码

代码语言:javascript
运行
复制
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的代码

代码语言:javascript
运行
复制
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()

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-09 06:14:14

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

我的代码现在

代码语言:javascript
运行
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65207026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档