Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Wed 27/04/2005 23:36:17

Title: how do i make it so a dialog option runs a script?
Post by: on Wed 27/04/2005 23:36:17
 Im making a rpg game and I wanna make it so that when your talking to a thief and he asks you to give him all your money. If you say no i want it to go to my battle screen and if you say yes i want it to set my money variable to 0. Can anyone help me?
Title: Re: how do i make it so a dialog option runs a script?
Post by: Candle on Thu 28/04/2005 00:27:05
In the help file Pat .


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 text 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.
lose-inv X
Removes inventory item X from the current player's inventory. This does the same thing as the LoseInventory text 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 text 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:


Title: Re: how do i make it so a dialog option runs a script?
Post by: Ishmael on Thu 28/04/2005 14:46:23
And to make all the magic happen, you'll need to put something very much like this into the global script (it's for 2.62, if the new version has changed this, I appologise for providing outdated information. Haven't looked into 2.7 yet...):


function dialog_request(int val) {
  if (val == 1) {
    // code for run-script 1 goes here
  } else if (val == 2) {
    // code for run-script 2 goes here
  }
}


and so on, just add more else if (val == #) conditionals as you need them.
Title: Re: how do i make it so a dialog option runs a script?
Post by: TerranRich on Sat 30/04/2005 03:57:59
For more help: http://bfaq.xylot.com/#coding02
Title: Re: how do i make it so a dialog option runs a script?
Post by: on Sun 01/05/2005 03:32:53
thanks, i figured it out