Dialog Topic Question [SOLVED]

Started by NiksterG, Tue 15/03/2005 05:40:13

Previous topic - Next topic

NiksterG

At one point in my game, the main character talks with another character. Depending on what choices the user picks, I want the game to either bring the other character to a different room and give the player a new item, or just bring main character to different room..

Here is the script so far:

@1Ã,  // option 1
Ã,  Ã,  Ã,  // characters talk here (actual dialog)
option-on 2
option-on 3
option-off 1
return

@2Ã,  // option 2
Ã,  Ã,  Ã,  Ã, // more dialog, character asks for item. If main character has it, he loses it. If not, go to room 7

@3Ã,  // option 3
Ã,  Ã,  Ã,  Ã, // more dialog, a fight happens, other character dies, goes to other room. Main character get new item.
add-inv 8
stop




Please help! If you don't understand me (Which most people don't :'() please let me know how I can clarify!!!
Check out my games! (Not all made with AGS)

Gilbert

Use run-script in place of more "complicated" stuff which can't be handled natively via dialog scripts.

strazer

Yes, since dialog scripts don't support conditionals, you have to do something like this:

@2  // option 2
//...some dialog
run-script 72 // call the dialog_request function with 72 as parameter

Then go to menu "Script" -> "Global script":
Code: ags

// main global script

function dialog_request(int parameter) {

  if (parameter == 72) { // if "run-script 72" used
    if (character[GetPlayerCharacter()].inv[THE_ITEM_NUMBER]) { // if player has the inv item
      character[GetPlayerCharacter()].inv[THE_ITEM_NUMBER] = 0; // lose all of inv item
    }
    else { // if player doesn't have the inv item
      NewRoom(7); // go to room 7
    }
  }
//else if (parameter == X) { // and so on, for other run-script commands

}


Search the forum for dialog_request, you'll find a lot of threads about this.

NiksterG

Um, ok, I think I get it... butÃ,  just one question: right in the beginning of the script, where it says

function dialog_request (int parameter) ...

Do I have to put in something for "parameter", or can I just write what it says? ???

Other than that, I think I've got it. Thanks a bunch!!! ;D
Check out my games! (Not all made with AGS)

Bernie -logged off-

The 'parameter' integer only indicates the script to run from the dialog script editor.

You could also call it 'sniffletoe', as long as you compare to the integer name specified in function dialog_request.

Example:

function dialog_request(int sniffletoe) {

Ã,  if (sniffletoe == 1) {Display("Sniffletoe!");}

Ã,  if (sniffletoe == 2) {Display("Wear safety goggles! It's for safety!");
  QuitGame(0);}

}

If you open your dialog script and put this into it...

run-script 1

...it will  run the commands specified under 'if (sniffletoe ==1) {}'.
run-script 2 would run the commands within 'if (sniffletoe ==2) {}' and so on.

You can have as many of these as you want. You can also post as many commands as you want in them.

NiksterG

Quote from: Bernie -logged off- on Tue 15/03/2005 17:58:19

You could also call it 'sniffletoe'

That was an interesting choice of words... ::) Anyway, I tried out your methods, and they worked. My game is now a bit more interesting, thanks to you. Thank you very much for your help. ;)
Check out my games! (Not all made with AGS)

GarageGothic

Actually, I've been wondering -- is there a limit for the max. number of dialog requests?

strazer

Well, since the parameter is an integer, there are "only" 2,147,483,647 numbers you can use (double that if you can pass negative numbers, haven't checked).
Should be sufficient, no? ;)

GarageGothic

#8
Oh crap, I have to ask CJ to raise that number  ;D

Thanks for confirming that there aren't any abitrary limits. I'm always watching the system limits, and for some reason I get suspicious whenever a feature seemingly doesn't have one (I still don't quite believe that there isn't any max. number of fonts).

Knowing this, I can safely number them by character (i.e. 1XXX = COP, 4XXX = BARTENDER etc.).

NiksterG

Ok, I'm having problems now with the script (poor me):

I am trying to make a third {else if} thingy, but everytime I try to test the game, I get a scripting error saying   "Parse error at expr near '185' ". I have no idea how this happened, I followed your instructions to the letter. I need help!!! (Again!) :P
Check out my games! (Not all made with AGS)

strazer

You have probably used a single = instead of ==.
Use one = to assign a value, i.e.
  variable = 12;
and two == to do a comparison, i.e.
  if (variable == 12) {

If you still have problems, please post the actual code you're using.

NiksterG

No, I used two ==.Ã,  However, I just retyped the script into the window, and it worked. Go figure. ::)

Thank you for your help, I think I'm good now. I'll let you know if I get ANOTHER problem. ;) Thank again!!!
Check out my games! (Not all made with AGS)

SMF spam blocked by CleanTalk