visual studio和lua在等待输入时出错

如标题所述,Visual Studio很烦人,并且做事情不正确。

这是我的代码,应该可以工作

while true do
    local attempts = 3
    local RNG = math.random(10)
    if attempts ~= 0 then
        print(RNG)
        local Input = io.read("n")
        if Input == RNG then
            print("你猜对了! :" .. RNG)
            break
        elseif Input > RNG then
            print("低!")
        else
            print("高!")
        end
    end
end

它会出现错误,因为它没有等待用户实际输入然后继续到下一步检查是否相同,当然你不能将一个nil与数字进行比较并停止,我已经安装了扩展的lua和lua debug,还需要设置其他东西吗,我在linux上,但我不认为会有任何区别,但我需要提到它,感谢帮助。谢谢大家。

原文链接 https://stackoverflow.com/questions/70489312

点赞