Contents Up Previous Next

Text display / Speech functions

Display
DisplayAt
DisplayAtY
DisplayMessage
DisplayMessageAtY
DisplayTopBar
GetDialogOption
RunDialog
SetDialogOption
SetSkipSpeech
SetSpeechFont
SetSpeechStyle
StopDialog


Display

Display (string message, ...)
Displays a message to the screen. It will be displayed in the standard message box, and centred in the middle of the screen.

You can insert the value of variables into the message. For more information, see the string formatting section.

Example:

int my_counter;
Display ("The counter is currently set to %d.", my_counter);
will replace the '%d' with the value of the variable "my_counter".

NOTE: Display is a blocking function - that is, control will not return to the script until the player has removed the text window (by pressing a key or clicking the mouse). While the window is displayed, all other processing, like animations and interface display, are disabled. This is usually used for responses to the player LOOKing at things.

See Also: DisplayAt, DisplayMessage, Character.Say, DisplayTopBar, StrFormat


DisplayAt

DisplayAt(int x, int y, int width, string message, ...)

Identical to the "Display" function, only this allows you to define the position and size of the window where the text is displayed. The X and Y variables define the co-ordinates of the upper-left corner of the window.

The WIDTH variable defines the maximum width of the window. The height is then automatically calculated so that the message fits into the window.

You can insert the value of variables into the message. For more information, see the string formatting section.

Note: This is a blocking call. See the "Display" help for more information.

Example:

DisplayAt (50,50,100, "This is a message");
will display the message at coordinates 50,50 in a box 100 pixels wide.

See Also: Display, DisplayAtY


DisplayAtY

DisplayAtY (int y, string message)
Similar to the Display function, except that this will display the message box at the specified Y location on the screen. The Y defines the co-ordinate of the top of the message box. The horizontal positioning will be automatically calculated as usual.

Example:

DisplayAt (50, "This is a message");
will display the message at y coordinate 50.

See Also: Display, DisplayAt


DisplayMessage

DisplayMessage (int message_number)
Identical to the Display function, but this uses a message text defined in the Room Editor rather than in the script. It will either use a message from the current room, or a global message (if message_number >= 500).

Example:

DisplayMessage(220);
will display the message 220 of the Room message editor.

See Also: Display, DisplayMessageAtY


DisplayMessageAtY

DisplayMessageAtY (int message_number, int yposition)
Identical to the DisplayMessage function, except that the text box is positioned with its top at YPOSITION, the same way as DisplayAtY works.

This is useful if you have an important graphic in the middle of the screen that the text box would normally cover up - with this function you can place the message above or below it.

Example:

DisplayMessageAtY(527, 200);
will display global message 527, in the lower half of the screen.

See Also: DisplayAtY, DisplayMessage


DisplayTopBar

DisplayTopBar(int y, int text_color, int back_color, string titleText, string message, ...)
Displays a message in a text window, with a caption bar on top of it.

This displays MESSAGE in a similar way to the normal Display command, but above the text window a caption bar will be displayed with TITLETEXT in it. This method was used in some early Sierra games to indicate who was talking by having their name in the caption, and can be handy if you don't want to draw a talking view for a character.

You can insert the value of variables into the message. For more information, see the string formatting section.

The Y parameter specifies the Y location on the screen where the message box will appear. The default is 25.

The TEXT_COLOR parameter specifies the text colour of the top bar, and the BACK_COLOR specifies the background colour of the top bar.

You can pass 0 for Y, TEXT_COLOR or BACK_COLOR - if you do, it will use the setting you used last time.

There are a couple of game variables available which can further customize the look of the bar. You can change these before calling DisplayTopBar.

game.top_bar_bordercolor sets the colour used for the bar's border (set to the same colour as the backcolor if you don't want a border)
game.top_bar_borderwidth sets the width of the bar's border, in pixels (default 1)
game.top_bar_font sets the font to use for the top bar. The default is -1, which means that the current Normal font is used. Set it to a specific number to use that font instead.

Example:

DisplayTopBar(25, 8, 7, "Evil wizard", "Get out of my house and never return!");
will display "Get out of my house and never return!" in the message box, with the caption bar reading "Evil wizard". The message box will have dark grey text on a light gray background.

See Also: Display, DisplayAt


GetDialogOption

GetDialogOption (int topic, int option)
Finds out whether an option in a conversation is available to the player or not.

TOPIC is the topic number, from 0 to the number of topics - 1. Find this out in the Room Editor.

OPTION is the option number within that topic, from 1 to whatever the highest option is for that topic.

The return value can have the following values:

eOptionOff
  The option is disabled - the player will not see it
eOptionOn
  The option is enabled - the player can now see and use it
eOptionOffForever
  The option is permanently disabled - no other command can ever turn
  it back on again.
These are the same as the options passed to SetDialogOption.

Example:

if (GetDialogOption (4, 2) != eOptionOn)
  Display("It's turned off");
Will display a message if option 2 of topic 4 is not currently switched on.

See Also: SetDialogOption


RunDialog

RunDialog (int topic)
Starts a conversation using topic number TOPIC. This is identical to the "Run dialog topic VAL" room interaction command.

NOTE: The conversation will not start immediately; instead, it will be run when the current script function finishes executing.

If you use this command from within the dialog_request function, it will specify that the game should return to this new topic when the script finishes.

Example:

RunDialog(3); 
will start conversation topic number 3.

See Also: SetDialogOption


SetDialogOption

SetDialogOption (int topic, int option, DialogOptionState)
Changes whether an option in a conversation is available to the player or not. This allows you to add extra options to a conversation once the player has done certain things.

TOPIC is the topic number, from 0 to the number of topics - 1. Find this out in the Room Editor.

OPTION is the option number within that topic, from 1 to whatever the highest option is for that topic.

The DialogOptionState controls what happens to this option. It can have the following values:

eOptionOff
  The option is disabled - the player will not see it
eOptionOn
  The option is enabled - the player can now see and use it
eOptionOffForever
  The option is permanently disabled - no other command can ever turn
  it back on again.
These are equivalent to the option-off, option-on, and option-off-forever dialog commands.

Example:

if (GetGlobalInt(10)==1)
    SetDialogOption(4, 2, eOptionOn);
will enable option 2 of topic number 4 if the Global Integer 10 is 1.

See Also: GetDialogOption, RunDialog, StopDialog


SetSkipSpeech

SetSkipSpeech (int new_mode)
Changes whether the player can skip speech text by clicking the mouse. This option is initially set in a checkbox in the Main tab of the editor, but this function allows you to change it at run-time. The value of NEW_MODE means the following:
0  player can skip text by clicking mouse or pressing key
1  player can skip text by pressing key only, not by clicking mouse
2  player cannot skip text with mouse or keyboard
3  text does not time-out; player must click mouse or press key each time
4  player can skip text by clicking mouse only, not by pressing key
Example:
SetSkipSpeech(2);
will make the player unable to skip the text by pressing a mouse button or a key.


SetSpeechFont

SetSpeechFont (int font_number)
Changes the font used for character speech. FONT_NUMBER must be from 0 to the number of fonts you have. By default the only options are 0 and 1.

Example:

SetSpeechFont (5);
will change the character’s speech font to 5.

See Also: SetNormalFont


SetSpeechStyle

SetSpeechStyle(SpeechStyle)
Changes the way in which speech text is displayed. This modifies the setting originally set in the editor. SpeechStyle can be:
eSpeechLucasarts
  speech text over character's head
eSpeechSierra
  close-up portrait of character
eSpeechSierraWithBackground
  close-up portrait + background window for text
eSpeechFullScreen
  QFG4-style full screen dialog pictures
Example:
SetSpeechStyle(eSpeechSierra);
will change the speech style to a close up portrait of the character.


StopDialog

StopDialog ()
This command can only be used from within the dialog_request function. It tells AGS that when dialog_request finishes, the whole conversation should stop rather than continuing with the dialog script.

You can use this function to end the conversation depending on whether the player has/does a certain thing.

Example:

 function dialog_request (int dr) {
 if (dr==1) {
   character[EGO].AddInventory(iPoster);
   StopDialog();
 }
will give the player the inventory item 3 and then end the conversation.

See Also: SetDialogOption

Browser Based Help. Published by chm2web software.
1