¿Is it possible to jump a script line?

Started by eduarazo, Wed 03/12/2008 12:48:13

Previous topic - Next topic

eduarazo

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

Gilbert

One simple way is to use a variable to track the condition of the room.

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


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

if (visited==0) visited=1;
else {
  //do whatever you want for player *not* entering the room for the 1st time here
}

Ghost

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 ;)

Trent R

There's also the Game.DoOnceOnly(string) function, look it up in the manual.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Pumaman

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 function as Trent suggests so that he only says it the first time.

eduarazo

Thanks all, I tried the first option and works well

SMF spam blocked by CleanTalk