Text input boxes can be very useful, especially when you are creating a module to help teach physics (multiple choice doesn't really cut it). Here is a helpful overview of the DisplayInputBox function that I found on the NWN Vault:
Calls up a string input box, with text description field and script callback for the results
Usage:
This script function displays a text input box popup on the client of the player passed in as the first parameter.
oPC - The player object of the player to show this message box to
nMessageStrRef- The STRREF for the Message Box message.
sMessage - The text to display in the message box. Overrides anything
- indicated by the nMessageStrRef
sOkCB - The callback script to call if the user clicks OK, defaults
- to none. The script name MUST start with 'gui'
sCancelCB - The callback script to call if the user clicks Cancel, defaults
- to none. The script name MUST start with 'gui'
bShowCancel - If TRUE, Cancel Button will appear on the message box.
sScreenName - The GUI SCREEN NAME to use in place of the default message box.
- The default is SCREEN_STRINGINPUT_MESSAGEBOX
nOkStrRef - The STRREF to display in the OK button, defaults to OK
sOkString - The string to show in the OK button. Overrides anything that
- nOkStrRef indicates if it is not an empty string
nCancelStrRef - The STRREF to dispaly in the Cancel button, defaults to Cancel.
sCancelString - The string to display in the Cancel button. Overrides anything
- that nCancelStrRef indicates if it is anything besides empty string
sDefaultString - The text that gets copied into the input area,
- used as a default answer
sVariableString- Doesn’t do anything right now
void DisplayInputBox( object oPC, int nMessageStrRef,
string sMessage, string sOkCB="",
string sCancelCB="", int bShowCancel=FALSE,
string sScreenName="",
int nOkStrRef=0, string sOkString="",
int nCancelStrRef=0, string sCancelString="",
string sDefaultString="", string sVariableString="" );
Example script and callback, where “gui_input_ok” is the callback script activated when the user presses “OKAY”:
script input_test::
void main()
{
DisplayInputBox( OBJECT_SELF, 0, "Test Message", "gui_input_ok", "", 1,
"SCREEN_STRINGINPUT_MESSAGEBOX", 0, "OKAY", 0, "CANCEL", "DefaultSTR", "VariableSTring" );
}
script gui_input_ok::
void main( string sInput )
{
ActionSpeakString( sInput );
}
An important thing to note is that the script called when the user clicks "OKAY" is that the script's name must begin with "gui_". In this example it is called "gui_input_ok".