If Dialog Ends [SOLVED]

Started by Scorpio82, Thu 16/11/2006 02:22:47

Previous topic - Next topic

Scorpio82

 I'm trying to set a variable so that the first time you end a dialog with a character, the character will say something a little extra, and everything after that will be just a normal dialogue ending.

Here's a sample of what I have:

________________


int extrastuffÃ,  Ã, //this is the variable I'm using to keep track of the ending

dDialogue.Start(); //initiate dialogue between characters

Ã,  Ã,  if (extrastuff == 0) { //if this is the first time they ended the conversation
Ã,  character[].Say("And don't forget that stuff I told you.");
Ã,  Ã, extrastuff = 1;
Ã,  Ã,  }
Ã,  Ã, 
Ã,  Ã,  else if (extrastuff == 1) { //if this is not the first time they ended the conversation
Ã,  Ã,  }

_________________

I thought it would play the extra scripting after exiting the dialog, but it just plays it before the dialogue even starts.

I think there should be some kind of condition that checks to see if the dialogue has ended or not but I can't find it anywhere in the reference.Ã, 

I also tried running this as a dialog_request from the Dialogue Editor, but it can't read the room's "extrastuff" variable.

Ashen

Real quick, since this has been (sort of) dealt with before.
Quote from: The Manual, Dialog.Start
NOTE: The conversation will not start immediately; instead, it will be run when the current script function finishes executing.
Which is why your code executes before the dialogue runs. The general solution to that (I think) is to split to commands between two 'Run script' interactions - one that ends with Dialog.Start() and one that contains the code you want to run after the dialog. Do a forum search for RunDialog to see if there's another solution.

However, in your case - why not just move the extrastuff variable into the Global Script, so dialog_request can use it? Or have two 'Goodbye' options in the dialog, the first of which contains the extra stuff and turns itself off and the other on, e.g.:
Code: ags

@4
NPC: Goodbye.
NPC: And don't forget that stuff I told you.
option-off 4
option-on 5
stop
@5
NPC: Goodbye.
stop

(Where option 5 is initially set not to display.)
I know what you're thinking ... Don't think that.

Scorpio82


KA-CHING!  ;D

Second option works.  Thank you very much.

I'll have to read more into global variables.  So far I haven't gotten any to work, but it's best I do it before I get too deep into programming.

Khris

To make a variable global, declare it at the beginning of the global script, then export it and import it in the header.
(I usually declare my global vars directly above the function that's going to use them, but that's a matter of personal taste.)

Example:
Code: ags
// top of global script
int var;
export var;

String name;
export name;

int testarray[10];
export testarray;    // export only the name

function doStuff(int a, bool b) {   // not necessary to export functions
  if (b) Display("%d", a);
}


Then, in the header:
Code: ags
import int var;

import String name;

import int testarray[10];    // <- dimension required here!

import function doStuff(int a, bool b);   // just like the declaration


This will add the names to AGS's auto-complete, too. Especially useful for functions.

Btw, when importing the function in the header, you can use different names for the parameters.
That way, you can keep a function with many parameters nicely short and readable, e.g. by declaring function doStuff(int noo) {...} instead of having to type number_of_objects over and over again.
Using import function doStuff(int number_of_objects); then will come in handy when auto-complete kicks in.

SMF spam blocked by CleanTalk