Contents Up Previous Next

Text display / Speech functions

Display
DisplayAt
DisplayAtY
DisplayMessage
DisplayMessageAtY
DisplaySpeech
DisplaySpeechAt
DisplaySpeechBackground
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 values of variables using "%d" and "%s" in the message. To insert the value of an integer variable, use %d, to insert a string use %s.

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, DisplaySpeech, 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 width of the window. The height is then automatically calculated so that the message fits into the window.

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, int the lower half of the screen.

See Also: DisplayAtY, DisplayMessage


DisplaySpeech

DisplaySpeech (CHARID, string message)
Displays the text MESSAGE as speech above the specified character's head. The text will remain on screen for a limited time, and the user may or may not be able to click it away depending on the setting of "Player can't skip speech text". The text displayed by this function looks identical to that used by the dialog system.

NOTE: This function allows variables like "%d" and "%s" in the message.

Example:

DisplaySpeech (EGO , "My name is ego");
will display the message above the character’s EGO head like the LEC games and play the character’s talking animation.

See Also: Display, DisplaySpeechAt, DisplaySpeechBackground


DisplaySpeechAt

DisplaySpeechAt (int x, int y, int width, CHARID, string message)
Similar to DisplaySpeech, except that the text is displayed with its top left corner at (X,Y), in an area WIDTH wide.

You can use this function to write the character's speech text anywhere you like, and AGS will still play the character's talking animation and so on if appropriate.

NOTE: This function does not support QFG4-style speech.

Example:

DisplaySpeechAt (220, 20, 100, EGO , "My name is ego");
will display the message in the top right corner of the screen, and play the character's talking animation.

See Also: DisplaySpeech, DisplaySpeechBackground


DisplaySpeechBackground

DisplaySpeechBackground (CHARID, string message)
Similar to DisplaySpeech, except that this function returns immediately and the game continues while the character is talking. This allows you to have characters talking in the background while the player does other things. Note that the character's talking animation is not played if this function is used.

This command works by creating a text overlay with an automatic removal time delay. The overlay ID is returned by this command, so you can save it for use later with IsOverlayValid and RemoveOverlay, if you want to remove the text prematurely.

All background speech is automatically removed when a normal DisplaySpeech command is used (unless you set the global variable game.bgspeech_stay_on_display to 1).

Example:

DisplaySpeechBackground (MAN, "Hey, why don’t you talk to me?");
will display the message above character MAN's head without pausing the game.

See Also: DisplaySpeech


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:

0   The option is disabled - the player will not see it
1   The option is enabled - the player can see and use it
2   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) != 1)
  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.

Example:

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

See Also: SetDialogOption


SetDialogOption

SetDialogOption (int topic, int option, int new_state)
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.

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

0   The option is disabled - the player will not see it
1   The option is enabled - the player can now see and use it
2   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,1);  
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
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 (new_style)
Changes the way in which speech text is displayed. This modifies the setting originally set in the editor. NEW_STYLE can be:
SPEECH_LUCASARTS     speech text over character's head
SPEECH_SIERRA        close-up portrait of character
SPEECH_SIERRABKGRND  close-up portrait + background window for text
SPEECH_FULLSCREEN    QFG4-style full screen dialog pictures
Example:
SetSpeechStyle (SPEECH_SIERRA);
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) 
    { AddInventory(3);
      StopDialog();  }
will give the player the inventory item 3 and then end the conversation.

See Also: SetDialogOption