"end" 预期(在第3行关闭 "while")附近的 "<eof>" 处应该是结束符。

我完全不懂Lua,但已经多次遇到了这个错误“'end' expected (to close 'while' at line 3) near ''"。我已经在网上寻找答案但没有成功,所以我希望有人能帮我解决这个问题,非常感谢。

以下是我的代码:

print(“欢迎来到迷宫”)

while input~="leave" do

    print(“你首先想做什么?离开还是检查?”)

    input = io.read()

    if input ==“inspect” then
        print(“你冒险走向迷宫。”)
    end

    if input=="leave" then
        print(“你转身就跑了。”)
    end
点赞
用户5830773
用户5830773

我从未见过lua,但我认为阅读错误信息将是解决方案:

预期 'end'(用于关闭第3行的'while')

所以我需要将 end 代码加入:

print ("欢迎来到迷宫")

while input ~= "离开" do

    print ("你想先做什么?离开还是检查?")

    input = io.read()

    if input == "检查" then
        print (" 你向迷宫进发。")
    end

    if input == "离开" then
        print ("你转身逃走。")
    end

end
2016-01-29 11:58:36