how do i make it so a dialog option runs a script?

Started by , Wed 27/04/2005 23:36:17

Previous topic - Next topic

Pat

 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?

Candle

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:



Ishmael

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.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

TerranRich

Status: Trying to come up with some ideas...


SMF spam blocked by CleanTalk