views:

302

answers:

2

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?

+2  A: 

Take a look at the io library, which by default has standard-input as the default input file:

http://www.lua.org/pil/21.1.html

Amber
+4  A: 
local answer
repeat
   io.write("continue with this operation (y/n)? ")
   io.flush()
   answer=io.read()
until answer=="y" or answer=="n"
lhf