在'<eof>'附近预期'结束''在第3行关闭'而''

时间:2016-01-29 11:51:36

标签: lua

我是Lua的新手,我多次得到这个错误“'结束'预期(关闭'而在第3行')附近''”我已经检查过在网上找到答案但没有运气所以我是希望有人能帮我解决这个问题,非常感谢

这是我的代码:

print ("Welcome to the maze")

while input ~= "leave" do

    print ("What do you want to do first? Leave or inspect?")


    input = io.read()

    if input == "inspect" then
        print (" You venture towards the maze.")
    end

    if input == "leave" then
        print ("You turn around and run.")
    end

1 个答案:

答案 0 :(得分:6)

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

  

&#39;端&#39;预期(关闭&#39;而第3行)

所以我需要将end放到代码中:

print ("Welcome to the maze")

while input ~= "leave" do

    print ("What do you want to do first? Leave or inspect?")

    input = io.read()

    if input == "inspect" then
        print (" You venture towards the maze.")
    end

    if input == "leave" then
        print ("You turn around and run.")
    end

end