Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Puppetsj on Fri 31/10/2008 09:28:34

Title: Varying dialog responses depending on the state of a variable? (or other ways)
Post by: Puppetsj on Fri 31/10/2008 09:28:34
I'm trying to have a single dialog option have different responses from the character you're talking to based on the state of a variable, but I can't see how. So for example if I have a dialog option:

"Wanna go see a movie?"

I want the answer to that dialog option to depend on the variable 'isBored', so if it's set to 1 the character will respond with a yes but if it's not he'll say no.
Title: Re: Varying dialog responses depending on the state of a variable? (or other ways)
Post by: Khris on Fri 31/10/2008 09:38:25
In the dialog script, instead of the character's reply, put "run-script 1".
Then go to the dialog_request function in the global script and change it (or create it):
function dialog_request(int p) {
  if (p == 1) {         // run-script 1 calls dialog_request(1);
    if (isBored) {
      cGuy.Say("Yeah, sure!");
      ...
    }
    else cGuy.Say("Nah, I'm busy here.");
  }
}
Title: Re: Varying dialog responses depending on the state of a variable? (or other ways)
Post by: Puppetsj on Fri 31/10/2008 09:46:17
Thanks.

Although now I'm having other trouble. I wanted to have a variable that throughout the course of the game would be added to / detracted from depending on the choices you make, and having it affect characters, events and dialogs. So I set up a global variable... and now it seems I can't use it with this dialog_request function.
What are my options for solving this?

My thinking here is global variables can be used across the whole game whereas other types can't... but I have a sneaking suspicion I'm wrong about that.

Ah, figured it out. I hope.