Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: eduarazo on Wed 03/12/2008 12:48:13

Title: ¿Is it possible to jump a script line?
Post by: eduarazo on Wed 03/12/2008 12:48:13
Hi guys,

I will try to explain my problem, excuse my english.

In my game there's a prison and you can access to it from the street trough a door. Every time the playable character enters to the prison, this door closes behind him with a sound ("Pom!").

I want the main character to say something first time he enters the room (before the door closes), so I created a "first load" function with the PlaySound and Say commands. Logically, when the character enters the room not for first time the door have also to close and the door sound play, so I put a another time the PlaySound command at top of the room script.

Problem: when the character enters for first time the sound plays two times.

¿Can I put an ignore line command or something like this the end of the first load function to jump the PlaySound at the top of the room script?

Hope you understand anything xD
Title: Re: ¿Is it possible to jump a script line?
Post by: Gilbert on Wed 03/12/2008 13:02:32
One simple way is to use a variable to track the condition of the room.

Add on top of the room's script:
int visited=0;

Then, in the script for 'player enters the room' (not the 'first load' one), do something like:

if (visited==0) visited=1;
else {
  //do whatever you want for player *not* entering the room for the 1st time here
}
Title: Re: ¿Is it possible to jump a script line?
Post by: on Wed 03/12/2008 13:04:05
Aye. Or you can use the build-in HasBeenInRoom property.

if (!HasPlayerBeenInRoom(NumberOfYourRoom)) {
  PlaySound(NumberOfYourSound);
}

Result's the same, it just saves you one self-made variable ;)
Title: Re: ¿Is it possible to jump a script line?
Post by: Trent R on Wed 03/12/2008 13:23:01
There's also the Game.DoOnceOnly(string) function, look it up in the manual.


~Trent
Title: Re: ¿Is it possible to jump a script line?
Post by: Pumaman on Wed 03/12/2008 20:16:59
Quote from: Ghost on Wed 03/12/2008 13:04:05
Aye. Or you can use the build-in HasBeenInRoom property.

if (!HasPlayerBeenInRoom(NumberOfYourRoom)) {
  PlaySound(NumberOfYourSound);
}

Be careful of this one, if you use it in the current room it will always return true.

The easiest option is probably to put all your code in the "Player enters screen" event, and then use the Game.DoOnceOnly (http://www.adventuregamestudio.co.uk/manual/Game.DoOnceOnly.htm) function as Trent suggests so that he only says it the first time.
Title: Re: ¿Is it possible to jump a script line?
Post by: eduarazo on Thu 04/12/2008 08:16:21
Thanks all, I tried the first option and works well