Prompting the user for input

Posted by Cburke on Mon 12 Jul 2010 11:17 PM — 7 posts, 27,593 views.

#0
Is there a way to prompt the user for input (in Lua) in such a way that they can type their answer into the input line and it will go into a variable instead of to the "world"?

Thanks,

-C
Australia Forum Administrator #1
You can put up a dialog box:

http://www.gammon.com.au/scripts/doc.php?lua=utils.inputbox

I suppose you could create a temporary alias that matched "*" (everything), and wait until it fires, then delete it. Personally I like the dialog box better because it doesn't interfere with normal gameplay.
#2
Got it, thanks - it's working. One more question - is there a way to affect the text size/font in the dialog box? I see I can change it for the text input area - but how can I change it in the message in the box?

Thanks,

-C
Australia Forum Administrator #3
Sorry, the dialog box is largely fixed, apart from changing the text input font.
#4
Ok - thanks. What I was trying to do is display a small text table with options to choose from and have the user select an option by number. I wanted to use a monospace font for this so the table lines up properly.

I suppose I could do it with with a mini-window, but might be overkill. Let me know if you have any other thoughts.

Thanks,

-C
Australia Forum Administrator #5
Oh well in that case utils.listbox might help (or utils.choose). They let you put up a list of things.

http://www.gammon.com.au/scripts/doc.php?lua=utils.listbox


Failing that, you could do what you suggested earlier, and just display your options on the screen, but them type a simple alias, eg. "pick 5". Then "pick" is the alias and "5" is the one they chose. (So if you are displaying classes you could type "class 5" or "class mage").

If this is designed to be part of character selection for starting a new character, then my other suggestion of an alias that matches "*" might still work. Just be sure to disable it once they have finished picking stuff or they won't get far typing in commands. :)
#6
Thanks Nick - I'll explore both options.

-C