Dialog script

From Adventure Game Studio | Wiki
Jump to navigation Jump to search

This text is copied from the article Setting up the game, which is a very odd place for it in the manual, and so is reproduced here

This is NOT the same script language as the main text scripts use - it is a much simplified and easier to understand language specific to dialogs. Each topic has its own script file. When you click "Edit script" for the first time on a topic, all you will see is a number of lines starting with an '@' symbol. In the dialog script, these signify the starting points of the script for each option. For example, when the player clicks on option 3, the script will begin on the line following "@3". There is also a special starting point, called "@S". This is run when the conversation starts, before any choices are given to the player. This could be used to display a "Hello" message or something similar.

To display some speech, you begin the line with the character's SCRIPT NAME (not full name), followed by a colon, then a space, and then what you want them to say. For example, if my main character's script name is EGO, I would write

 ego: "I am very happy today because it's my birthday."

The character name is used by the system to choose the correct colour for the text. You can also use the special character name "narrator", which displays the text in the pop-up message box instead of as speech text; and the alias "player", which will say it as the current player character - useful if you don't know which character the player will be controlling when they speak the conversation.

If you just use ... as the text for a character to say, the game will pause briefly as if they are stopping to think, and nothing will be displayed.

To signal the end of the script for this option, place a "return" command on the last line of it. For example,

ego: "Hello. How are you?"
narrator: The man looks you in the eye.
otherman: ...
otherman: "I'm fine."

This tells the program to go back and display the choices again to the player. If you use "stop" instead of return, then the conversation is ended. You use this after the player saying "Goodbye" or something similar.

The dialog commands available are:

add-inv X Adds inventory item X to the current player's inventory. This does the same thing as the AddInventory script command, but is provided here because it is frequently used in dialogs.

give-score X Gives the player X points, and plays the score sound if appropriate.

goto-dialog X Switches the current topic to Topic X, and displays the current list of choices for that topic.

goto-previous Returns to the previous topic that this one was called from. If the dialog started on this topic, then the dialog will be stopped.

lose-inv X Removes inventory item X from the current player's inventory. This does the same thing as the LoseInventory script command, but is provided here because it is frequently used in dialogs.

new-room X Takes the player to room X, and aborts the conversation. Since this does not allow you to specify co-ordinates, you may need to use some Player Enters Screen logic in the target screen to place the character properly.

option-off X Turns option X for the current topic off, meaning it won't be displayed in the list of choices next time.

option-off-forever X Turns option X off permanently. It will never again be displayed, not even if an "option-on" command is used.

option-on X Turns option X for the current topic on, including it in the list of choices to the player next time they are displayed.

play-sound X Plays sound effect X, similar to the Play Sound interaction command.

return Stops the script and returns to the list of choices.

run-script X Runs global script function "dialog_request", with X passed as the single parameter. This allows you to do more advanced things in a dialog that are not supported as part of the dialog script. The "dialog_request" function should be placed in your game's global script file, as follows:

 function dialog_request (int xvalue) {
   // your code here

set-globalint GI VAL Changes script GlobalInt number GI to have the value VAL. This is equivalent to the SetGlobalInt script command, and allows you to quickly set things without having to go through a run-script just to set an int value.

set-speech-view NAME X Changes character NAME's talking view to X. NAME must be their script name, and X is the number of the new talking view. Use this to easily change their facial expression during a conversation.

stop Stops the conversation and returns the player to the game.