inputbox function in Lua

Case number:845813-988499
Topic:Game: Tools
Opened by:Tlaloc
Status:Closed
Type:Suggestion
Opened on:Friday, September 17, 2010 - 18:13
Last modified:Sunday, November 11, 2012 - 10:04

It would be useful for Lua to have an inputbox function.

In Visual Basic for Applications (VBA), the programming language used for macros in Microsoft Office, among other things, there is a function named InputBox. There are three arguments:

Inputbox(Prompt, Title, Default)

Title and Default are optional. Title defaults to the application name, i.e. Foldit, and Default defaults to a zero length string.

This function constructs a simple dialog that has a title bar, a label, a textbox, an OK button, and a Cancel button.

The function brings up the dialog and blocks further execution of the code until it returns, which happens when one of the buttons is clicked (Cancelling the script while the dialog is up will take down the dialog, too). The Prompt argument is placed into the label control on the dialog. The Title argument is placed onto the title bar of the dialog. The Default is used for the default text in the textbox. If a default is present, the text is selected when the dialog comes up, so that typing immediately replaces the default with what is typed.

The textbox has the focus when the dialog comes up, so that typing goes directly into the textbox.

The return value is always a string. For this to be useful in Lua, this means that we would need the math functions that allow parsing strings into numbers implemented as well.

This function would allow a Lua script to be able to gather information from a user with the minimum of implementation time. It isn't ideal if 15 pieces of information need to be gathered from the user, since that requires bringing up 15 inputboxes, but it would give our script at least some way of talking to the user with the minimum of development resources.

(Fri, 09/17/2010 - 18:13  |  4 comments)


Tlaloc's picture
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 08/04/2008
Groups: Mojo Risin'

One more thing. In VBA, pressing Cancel always returns a zero length string. In Lua, it would make sense for it to return nil, instead.

Tlaloc's picture
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 08/04/2008
Groups: Mojo Risin'

I put a full writeup on the wiki, with a picture of what an inputbox should look like: http://foldit.wikia.com/wiki/Lua_Functions_That_Should_Be_Implemented#Inputbox_Function

Joined: 06/17/2010
Status: Open » Closed

Implemented in v2 LUA

Tlaloc's picture
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 08/04/2008
Groups: Mojo Risin'
Status: Closed » Closed

Done

Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons