So, I have a basic thing I do with most rooms where it stops the previous music, then plays that rooms music. BUT I have 2 closeups in a room, where i dont want this to happen. I used...
if (player.PreviousRoom == 7){}
else
Game.StopAudio();
a03The_lab.Play();
Which I can prevent this happening if you enter back into the parent room from room 7. But I want to add room 6 too. I either break both or only get one working at a time.
Any ideas?
If I understand your code correctly, you could try:
if (player.PreviousRoom == 7 || player.PreviousRoom == 6){}
else
Game.StopAudio();
a03The_lab.Play();
If the previous room is 7 *OR* the previous room is 6.
Which you could rewrite more simply as:
if(player.PreviousRoom != 7 && player.PreviousRoom != 6)
Game.StopAudio();
a03The_lab.Play();
This is the logical inverse -- If the previous room is not 7 *AND* the previous room is not 6.
Also, only the first statement is contained within the conditional block. From the indentation, it's not clear if that's what you intended.
On an unrelated note, the absence of brackets is quite disturbing:
///YOU CAN DO THIS:
else
{
Game.StopAudio();
a03The_lab.Play();
}
//...OR THIS:
else
Game.StopAudio();
a03The_lab.Play();
//...BUT NEVER THIS:
else
Game.StopAudio();
a03The_lab.Play();
Quote from: Monsieur OUXX on Fri 17/04/2015 09:32:04
On an unrelated note, the absence of brackets is quite disturbing:
(laugh)
Right...
now I have the following code.
if (player.PreviousRoom == 7 || player.PreviousRoom == 6){}
else
Game.StopAudio();
a03The_lab.Play();
aDoor__generic__close.Play();
If I havent come from room 6 or 7, it does not do...
Game.StopAudio();
a03The_lab.Play();
but still does...
aDoor__generic__close.Play();
any ideas :)
The code above will execute a03The_lab.Play() and aDoor__generic__close.Play() regardless of the result of the if statement.
Use braces to group the statements into a code block:
if(player.PreviousRoom == 7 || player.PreviousRoom == 6)
{}
else
{
Game.StopAudio();
a03The_lab.Play();
aDoor__generic__close.Play();
}
Just thought this myself. It was a *DOH moment.
Thanks!
For a slightly more robust solution, try this:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=50363.msg636486911#msg636486911