LF: Script for Global BGM and/or play different BGM other than listed in map properties?

I have a background music set for a map but sometimes an event happens and that same map temporarily needs an entirely different BGM.

I tried doing this by setting up a parallel process or an autorun instructing RPG Maker to change the music. But that does not work real great. What that does is play the BGM set in the map properties for a few seconds and then switch to the BGM listed in the event. That is an issue when you want the music to keep playing when you enter other rooms or other areas tied to that map.

I got around this by duplicating the map and using switches to tell RPG Maker to go to the duplicate map but that is a lot of duplicating when the plot is thickening in a certain area.

This is a downgrade from the PS1 version of RPG Maker. Their autorun events (called intro events) prioritized the BGM outlined in the event over the map BGM if change BGM is the first thing listed in the autorun. VX Ace does not do this.

So, I am wondering if a script exists where I can play a different BGM for a map if a certain switch is on.

I am also getting close to developing a case where a BGM needs to play across all maps temporarily (until the switch for that is turned off) I have not decided if that would include battles or not so both options for that would be nice.

Does anything like either of these exist?
You could just not give the map a BGM in the map properties, then use a parallel event to start playing one depending on switch conditions or whatever.
If you were talking about a single switch or a small group of switches that alter the BGM currently playing on the current map and many other maps, that would be easy. The problem would be to make them play quick enough for your birds not to lose their temper. 😀 Kinda joking here.
It would have to keep track of the previous bgm. That is included by default so it shouldn'tbe a problem here.
Just uncheck the auto-BGM function in the map info and make a parallel processing event that plays music at certain intervals. You do not need a script for this at all.

... What @ATT_Turan said, essentially.

EDIT: That or you could meticulously keep track of all of your music in one common event and do conditional branch work to make music play over others, but I can see that getting overwhelming extremely quickly.

Also you still need to make a parallel processing event that holds it.
That method has a problem. It also overrides transportation music such as boat or ship. Setting it up as a parallel process using switches does not work right. I need the boat music to remain in tact but @ATT_Turan 's method breaks that.

So a script is required.
That method has a problem. It also overrides transportation music such as boat or ship. Setting it up as a parallel process using switches does not work right.
It works fine in my project. I run the game, it plays the BGM I specify. I get onto the airship, it plays the airship music. I get off it, it goes back to the BGM I specified in the event.

So I don't see a problem with the method - you may want to troubleshoot your event or post a screenshot of it for help.
How long did you stay on the airship? If it is only for a second, it does play the boat music but switches back to the event music after a second or so
As I said, it works exactly as expected for me.
This is my event. As soon as I get on a mount, it plays mount music for only a second before switching back to the overworld music outlined in this event after a second


1685041094113.png
Because the event is still running. You should almost never have a parallel or autorun event that doesn't turn itself off unless it's something that legitimately needs to keep getting executed constantly.

The way you wrote this, you're trying to start that BGM 60 times per second and contributing to lag in your game - so, yes, any time another part of the game tries to change it, this will change it right back.

You might want to look up some event tutorials so you know when to put in Wait commands, self switches, other pages, and erasing.

For now, if you simply add a second command of Erase Event, this should do exactly what you want.
It is still overriding mount music 🙁

1685043773217.png
I don't know what to tell you. In my test project, with no other scripts installed, it does not do that.
Don't worry, my feathered... friend?
Here I come with a working demo!

Original thread: https://forums.rpgmakerweb.com/threads/lf-script-for-global-bgm-and-or-play-different-bgm-other-than-listed-in-map-properties.157786/