Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: OldTimeGamer on Sat 15/08/2015 15:27:15

Title: Looking for specific function - cannot find it anywhere
Post by: OldTimeGamer on Sat 15/08/2015 15:27:15
Hello,

I need help about one specific script I cannot find anywhere.

I don't know how to explain it exactly, so I will try to say as simple as possible. I'm looking for function that can do this:

When my character does something particular, it will cause something to happen.

Example:
My character talks with stranger, who will reveal new location to the character. Therefore, after this dialog, my character will be able to enter the new location.

I always solve this problem with this aid - I make my character receive some item, so I can create function "Enter location after receiving the item."
Can I somehow do this without receiving an item?

I hope I made myself clear.

Have a nice day,
David
Title: Re: Looking for specific function - cannot find it anywhere
Post by: selmiak on Sat 15/08/2015 15:48:37
just use global variables, preferably bools.
Set the PlayerTalkedAboutX = true; in the dialog (declare it as false before of course), then in the repeadedly execute of the room with the exit to open up or the thing to happen check for
Code (ags) Select

if (PlayerTalkedAboutX == true) {
  //stuff that happens, remove walkable area, remove blocking object...
  PlayerTalkedAboutX=false;
}


set the variable to false at the end of the if clause to make it happen only once. use integers if you want the player to collect a certain amout of coins/stones/buttons/whatever and check for that specific number.
Title: Re: Looking for specific function - cannot find it anywhere
Post by: OldTimeGamer on Sat 15/08/2015 16:05:48
Thank you very much for you quick response.

One more question though. What is "PlayerTalkedAboutX"? Is it e.g. dDialog1?
Title: Re: Looking for specific function - cannot find it anywhere
Post by: Slasher on Sat 15/08/2015 16:29:57
QuoteWhat is "PlayerTalkedAboutX"?
it is just a variable boolean that selmiak added as an example.

PlayerTalkedAboutX could be called anything.

make a boolean in the global pane, give it a name, set it to false.
you can set it true at any point.

this is where you would use selmiak's example but using the boolean name you made.

Basic
Code (ags) Select
if (PlayerTalkedAboutX == true) {
  //Do this
  PlayerTalkedAboutX=false; // else do this
}


simple ;)

Title: Re: Looking for specific function - cannot find it anywhere
Post by: OldTimeGamer on Sat 15/08/2015 16:32:34
Thank you. And sorry for my lack of knowledge. You both helped me a lot. :)

Have a nice day.
Title: Re: Looking for specific function - cannot find it anywhere
Post by: Crimson Wizard on Sat 15/08/2015 17:06:45
More on variables in script here: http://www.adventuregamestudio.co.uk/wiki/Scripting_tutorial_part_1#Variables