Lua - get command line input from user?

RCIX picture RCIX · Nov 29, 2009 · Viewed 67.8k times · Source

In my lua program, i want to stop and ask user for confirmation before proceeding with an operation. I'm not sure how to stop and wait for user input, how can it be done?

Answer

lhf picture lhf · Nov 29, 2009
local answer
repeat
   io.write("continue with this operation (y/n)? ")
   io.flush()
   answer=io.read()
until answer=="y" or answer=="n"