Varying dialog responses depending on the state of a variable? (or other ways)

Started by Puppetsj, Fri 31/10/2008 09:28:34

Previous topic - Next topic

Puppetsj

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.

Khris

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):
Code: ags
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.");
  }
}

Puppetsj

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.

SMF spam blocked by CleanTalk