How to play music only if that music isn't playing?
A Voracious Latias
19 Jun 2020, 03:16I'm looking to play music in a certain area, it's easy enough to stop music and play a new theme in a different area... The problem comes when you re-enter the area where the music initially begins. I'm trying to do "If 'test.mp3' isn't playing, then play 'test.mp3'", or something along those lines. What do I put for the expression?
XanMag
23 Jun 2020, 18:13Not sure if it would work but...
- Play the music you want when entering the room.
- Set a flag. Name it something like music1playing.
- For every room that that music should be playing in, place an if script to check if music1playing is set. I’m not sure how Quest reads the after entering/before entering room scripts but you might want to try placing those scripts there? Test it out.
- If music1playing is set, do nothing. Else, play the .mp3 and set the flag.
- For a new area, do the same thing with new music.
I’ll try and drum something up for you and see if I can get it to work on my end.
So it’s basically the same thing you were doing but check for a flag instead of the .mp3.
Oh... and you are using the download version, not the online?
mrangel
23 Jun 2020, 20:40I'd probably guess something like making a game.changedbgmusic
scriptattribute:
if (TypeOf (this, "bgmusic") = "string") {
play sound (this.bgmusic, false, true)
}
else {
stop sound
}
Then when you enter the room, you can just do game.bgmusic = "name of sound file.mp3"
. Changing that attribute automagically plays the sound as long as it's not the same as the last one.