Lua 如何使消息重复
我正在编写一个代码来测试一些东西Lua 如何使消息重复,lua,Lua,我正在编写一个代码来测试一些东西 print('Hello! What is your name?') name = io.read() print('Hello '..name..'!') repeat print('What does a mute person say?') say = io.read() x = 'Nothing' z = 'nothing' if say == x then print('Correct!')
print('Hello! What is your name?')
name = io.read()
print('Hello '..name..'!')
repeat
print('What does a mute person say?')
say = io.read()
x = 'Nothing'
z = 'nothing'
if say == x then
print('Correct!')
elseif say == z then
print('Correct!')
else
print('Incorrect! Guess Again!')
end
until say = x or z
当我测试它时,一切正常,但是如果答案不正确,你就不能再尝试回答。可能是一个愚蠢的问题,但是,当答案不正确时,有没有办法让问题重复?循环条件
say=x或z
不应该编译,使用=
来测试相等性,而不是=
这还不够,say==x或z
相当于say==x
,因为如果x
不是nil
或false
,则x或z
的值为x
repeat
-- read say
until say == x or say == z
我不知道Lua,但循环条件看起来是错误的……在say==x或say==z之前,它不应该更像
吗?谢谢!这把它修好了。