Dialog functions are used to create and display a dialog, a menu which gives the user a choice of what to say next. The user's choice determines the outcome of the conversation. These functions make creating even complex and varied dialogs possible, with any number of levels, and without too much hassle.

The most important functions are addChoice and dialog. The properties affect only the look of the menu, and the other functions are seldom needed.

Properties


Functions




property DialogFont = none

This font used to render choices in the dialog menu. If none is specified, defaultFont will be used. The caret symbol "^" (ASCII 94) is used as the dialog bullet, so make sure the font you choose has the right icon in its place.




property DialogTextColor = COLOR_WHITE

Color of the dialog choices.




property DialogChoiceTextColor = COLOR_YELLOW

Color of the the dialog choice when the mouse pointer is over it.




property DialogMouseSprite = null

Chooses which sprite resource to use as the mouse pointer (a.k.a. cursor) whenever a dialog menu is active. If no dialog mouse sprite is assigned, the DefaultMouseSprite will be shown instead (assuming that is assigned!).




property DialogMouseFrame = 0

Chooses which frame of the DialogMouseSprite to display whenever a dialog menu is active.




function Dialog

Presents the dialog menu, waits for the user to choose one, clears the choices, and returns the chosen line's value. If only one choice exists, it is selected automatically. After the user chooses, all the choices are cleared automatically.

Returns

The value of the choice-code selected by the user.




function AddChoice (Code, String)

A dialog menu is built by adding choices, each with an associated choice-code, and presenting the list of choices to the user. When the user clicks a choice, the PresentDialog function returns the asociated choice-code, and the script can take appropriate action.

Parameters

Code Value that is returned later by Dialog if the user selects this choice from the menu.

String The string that is shown on the dialog menu. If the user selects this choice, it will be said by the active object.




function AddChoiceEcho (Code, String, Echo)

This is the same as addChoice, except it has an extra parameter that specifies whether this choice should be echoed by the active object in case it is chosen by the user.

Parameters

Code See addChoice.

String See addChoice.

Echo If true, the choice will be echoed, otherwise it will not.
Example
loop {     
     AddChoiceEcho(1, "Hello.", false);
     AddChoice(0, "Goodbye, Mr. Wizard.");     
     switch dialog {
     case 1:
          WIZARD: "Wait, let me guess..."
          "You were about to say ``Hello?''"
          EGO: "Wow!  That's amazing!"
     default:
          WIZARD: "Farewell, man of few words."
          return;
     }
}




function ReplaceChoice (OrigialCode, ReplaceCode, ReplaceText)

Replaces an existing choice on the dialog menu with a new choice, even while the dialog menu is being displayed.

Parameters

OrigialCode Code of choice to be removed.

ReplaceCode Code to replace the old one.

ReplaceText String index of the new string.
Returns

True, if the code existed, and removal was successful, or false if the code did not exist.