Murga-Projects Forums
User Prompt - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: User Prompt (/showthread.php?tid=292)


User Prompt - asafp - 02-27-2008 08:04 AM

Does anyone know how to prompt a user for input from a console application? Ideally, it would be able to mask the input for a password type field.


RE: User Prompt - mikshaw - 02-27-2008 08:34 AM

try io.read()

As a simple example, open up lua interactively.
type "var=io.read()"; it will wait for input.
type something else.
type "print(var)"; it will print whatever you typed previously.

I'm not sure about masking, but I'd be surprised if it's not available.


RE: User Prompt - iGame3D - 02-29-2008 08:34 AM

That is so basic. You think this would be step 2 after hello world.

Code:
--[[ lua command line user user input

o = the print() function
p = a prompt to the user
r = response from the computer
i =  i returns input waiting until line feed to continue execution
This example is all one line of code.
--]]

o ,p ,r = print, "Enter your name.","Hello "; o(p); i=io.read(); if i then o(r..i) end;


I had no  idea how to interactively give values to programs running in the command line until now. I'm sure its been in our telnet chat script forever and I totally overlooked it.

Thanks!


RE: User Prompt - mikshaw - 03-01-2008 06:59 AM

There is an interesting example of a text-based menu at lua-users:
http://lua-users.org/wiki/SampleCode (AsciiMenu)


RE: User Prompt - asafp - 03-05-2008 03:34 PM

Good examples. Thanx.