How to play music only if that music isn't playing?

I'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?

Not sure if it would work but...

  1. Play the music you want when entering the room.
  2. Set a flag. Name it something like music1playing.
  3. 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.
  4. If music1playing is set, do nothing. Else, play the .mp3 and set the flag.
  5. 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?

I'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.

Log in to post a reply.