RCI*_*CIX 16 lua user-input blocking wait
在我的lua程序中,我想在继续操作之前停下来并要求用户确认.我不知道如何停止并等待用户输入,怎么办呢?
lhf*_*lhf 30
local answer
repeat
io.write("continue with this operation (y/n)? ")
io.flush()
answer=io.read()
until answer=="y" or answer=="n"
Run Code Online (Sandbox Code Playgroud)
小智 7
我使用过像这样的代码.我将以一种可行的方式输入:
io.write("continue with this operation (y/n)?")
answer=io.read()
if answer=="y" then
--(put what you want it to do if you say y here)
elseif answer=="n" then
--(put what you want to happen if you say n)
end
Run Code Online (Sandbox Code Playgroud)