I am running lua script via scite in Ubuntu 12.04. When I execute an io.read program.
example: (each command is on a separate line)
io.write("Please enter a number: ")
user_input = io.read()
print(user_input)
When I execute the program, I don't get a separate pop-up dialogue window asking for the user input.
I get, on the right hand side of the code, the following output:
> lua5.1 "io_examples.lua"
Please enter a number: nil
I know this may sound stupid, but how do I get the pop-up output window asking the the user's input?
The nil returned by
io.readcould be a hint that an error has occurred during reading. You can check this by surrounding your io.read statement with an assert:local user_input = assert(io.read())or
local user_input = assert(io.read("*number")).My initial guess is that you received a: bad file descriptor caused because the standard input (
stdin) is not set.More information can be found here:
http://www.lua.org/pil/21.1.html
http://www.lua.org/pil/8.html