Hello, everyone!
So, I've employed Hime's Menu Music plugin, and it works largely as intended aside from an oversight that it would appear is an issue with the plugin itself: when the game is saved through the menu (but not through other means such as events), the music that plays after loading is the menu music rather than the music intended for that map that the game was saved in.
After doing a bit of digging and troubleshooting, I managed to find the reason for this, but I'm not sure how to actually fix it due to my inexperience with Javascript which is why I've come here for your help!
So, the main source of the issue is this script right here in rpg_objects.js:
Basically, what this script does is tell the game to remember what song is playing right before saving, and after a save file is loaded, play that song again.
The issue is that due to the nature of the Menu Music plugin, the song that is currently saving while in the menu is always going to be the menu music, unless you have the music disabled which would defeat the purpose.
An important thing to note is that the Menu Music plugin does have some code that saves the music played before opening the menu, which plays the music as intended once you return to the field.
So, I tried fiddling around with the code a bit in both rpg_objects.js (which I'll be nicknaming 'Objects' for the rest of this thread) as well as HIME_MenuMusic.js (nicknaming 'MM'), with little success. First, I tried to simply remove the part in Objects that tells the game to save the current BGM, hoping it would cause the onAfterLoad script to instead load the most recent saved BGM (our field music thanks to MM). This simply pulled a name undefined error, presumably since onAfterLoad was trying to pull this._bgmOnSave as opposed to MM's this._mapBgm.
So, my next attempt was to edit Objects to try to load this._mapBgm instead of this._bgmOnSave, but this yielded no results as well (I assumed that's because the two scripts are in different files, but with my lack of JS understanding I honestly can't say for certain).
With that not working, I thought that perhaps if I removed the entire script for saving and loading the BGM, the game would simply autoplay whatever it was supposed to for that map. Of course, it ended up just playing no music instead.
After that failed, my next attempt was to make onAfterLoad simply follow the same script that Menu Music does if you've turned the Replay code back on:
I had assumed this code would simply tell the game to play whatever music the map is assigned for Autoplay, but this pulled a Name Undefined error anyways.
Finally, my last resort was to try to pull those edits to Objects into MM instead, but after a variety of different alterations, I ultimately decided I'm probably not going to be able to figure this out through brute force like I usually do.
So, I was wondering if anyone knew how to get the game to play the map's intended music on load instead of the music playing on the menu before saving. I think our key to this is going to be MM's this._mapBgm, but I'm open to just about any ideas you guys might have on how to approach this!
Thank you!
So, I've employed Hime's Menu Music plugin, and it works largely as intended aside from an oversight that it would appear is an issue with the plugin itself: when the game is saved through the menu (but not through other means such as events), the music that plays after loading is the menu music rather than the music intended for that map that the game was saved in.
After doing a bit of digging and troubleshooting, I managed to find the reason for this, but I'm not sure how to actually fix it due to my inexperience with Javascript which is why I've come here for your help!
So, the main source of the issue is this script right here in rpg_objects.js:
Basically, what this script does is tell the game to remember what song is playing right before saving, and after a save file is loaded, play that song again.
The issue is that due to the nature of the Menu Music plugin, the song that is currently saving while in the menu is always going to be the menu music, unless you have the music disabled which would defeat the purpose.
An important thing to note is that the Menu Music plugin does have some code that saves the music played before opening the menu, which plays the music as intended once you return to the field.
So, I tried fiddling around with the code a bit in both rpg_objects.js (which I'll be nicknaming 'Objects' for the rest of this thread) as well as HIME_MenuMusic.js (nicknaming 'MM'), with little success. First, I tried to simply remove the part in Objects that tells the game to save the current BGM, hoping it would cause the onAfterLoad script to instead load the most recent saved BGM (our field music thanks to MM). This simply pulled a name undefined error, presumably since onAfterLoad was trying to pull this._bgmOnSave as opposed to MM's this._mapBgm.
So, my next attempt was to edit Objects to try to load this._mapBgm instead of this._bgmOnSave, but this yielded no results as well (I assumed that's because the two scripts are in different files, but with my lack of JS understanding I honestly can't say for certain).
With that not working, I thought that perhaps if I removed the entire script for saving and loading the BGM, the game would simply autoplay whatever it was supposed to for that map. Of course, it ended up just playing no music instead.
After that failed, my next attempt was to make onAfterLoad simply follow the same script that Menu Music does if you've turned the Replay code back on:
Code:
$gameMap.autoplay();
I had assumed this code would simply tell the game to play whatever music the map is assigned for Autoplay, but this pulled a Name Undefined error anyways.
Finally, my last resort was to try to pull those edits to Objects into MM instead, but after a variety of different alterations, I ultimately decided I'm probably not going to be able to figure this out through brute force like I usually do.
So, I was wondering if anyone knew how to get the game to play the map's intended music on load instead of the music playing on the menu before saving. I think our key to this is going to be MM's this._mapBgm, but I'm open to just about any ideas you guys might have on how to approach this!
Thank you!