Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: croquetasesina on Thu 28/02/2019 08:13:24

Title: run differents dialogs with the same character in differents moments
Post by: croquetasesina on Thu 28/02/2019 08:13:24
Hi guys!
First of all, thank you for your ever helps.

I've a room (hall), where is a character called Picklear. When run a dialog between characters, in one option I get a key. With this key I can go to other room. Well, then pick up an object (a rose) and I have to turn back to the first room (hall again) and run a different dialog. The dialog number 2. How can I run the dialog n2 when I came back?
Title: Re: run differents dialogs with the same character in differents moments
Post by: Khris on Thu 28/02/2019 08:19:01
The most basic check, and actually the one you might be looking for, is whether the player has acquired the rose.

Code (ags) Select
  if (player.hasInventory(iRose)) {
    dPicklear1.Start();
  }
  else {
    dPicklear2.Start();
  }


Obviously, this means if the player loses the rose at any point, they're back to dialog one. There are other ways to track game states, most commonly people use global variables.
Title: Re: run differents dialogs with the same character in differents moments
Post by: croquetasesina on Thu 28/02/2019 10:22:03
Thank you Khris.

Where can I read about the global variables? What is the method to do this action in GV? I think is more correct than losing the rose.
Title: Re: run differents dialogs with the same character in differents moments
Post by: Khris on Thu 28/02/2019 12:43:06
Create the variable via the project tree node called "Global variables". Right-click the empty list and click on "Add new variable..."
Use name "playerGotRose", type "bool" and initial value "false".

When the player receives the rose, use
Code (ags) Select
  playerGotRose = true;

In the talkto-Interaction, use
Code (ags) Select
if (playerGotRose) ...
Title: Re: run differents dialogs with the same character in differents moments
Post by: croquetasesina on Wed 06/03/2019 11:26:50
Thank you very much, I'm goint to try in this moment!! :)
Title: Re: run differents dialogs with the same character in differents moments
Post by: croquetasesina on Fri 05/04/2019 12:07:22
It's work fine!!! With all your help and a thousand readings and searches a day in the F1 manual I am able to move forward as I wanted. You do not know how much I really appreciate it. In not too long I will be able to present at least images and what the game is about :)
Title: Re: run differents dialogs with the same character in differents moments
Post by: croquetasesina on Fri 05/04/2019 12:10:00
Just one more thing. Is it normal to use a lot of global variables? Is that thinking about the possibilities, I think I will use many to activate and deactivate game options as I go forward and I do not know if this would be the correct method.
Title: Re: run differents dialogs with the same character in differents moments
Post by: Khris on Sun 07/04/2019 23:28:29
It depends on what you're using them for. If there's no other way to store game state, then using a global variable is not just fine but the only solution anyway.
If you have variables that you only need in a specific room script you don't have to create a GV though; you can simply declare a variable at the top of your room script.