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
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
}
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 ;)
There's also the Game.DoOnceOnly(string) function, look it up in the manual.
~Trent
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.
Thanks all, I tried the first option and works well