stop BGS while in menu

I noticed that whenever you go into the in-game menu / stats screen. The BGS continues to play, I would like a script that stops the sound the very instant the menu is brought up and resumes it when you exit the menu.
Try putting this on a blank script under materials and see if it works

Code:
class Scene_Base  alias start_stop_bgs start  def start    start_stop_bgs    if self.is_a?(Scene_Map)      $RPG_BGS.play unless $RPG_BGS.nil?    elsif self.is_a?(Scene_Menu)      $RPG_BGS = RPG::BGS      $RPG_BGS.stop unless $RPG_BGS.nil?    end  endend
Works well, however I do get this error the very instant I exit the menu

stopBGSmenuerror.png
Go to the help file, go to the 2nd tab, find RPG::BGS topic. Try to look for the play method there.


Can't check now as I'm at work and have no access to Ace here.
Go to the help file, go to the 2nd tab, find RPG::BGS topic. Try to look for the play method there.

Can't check now as I'm at work and have no access to Ace here.
Looked at it and closed the file almost instantly. That stuff looks way too complicated to me.
Hey, are you gonna fix this? Still waiting. 🙂
Untested (I don't have my VM open), but I'd recommend something like this instead:

Code:
class Scene_Menu < Scene_MenuBase  alias_method :start_stop_bgs, :start  def start(*args, &block)    start_stop_bgs(*args, &block)    Audio.bgs_stop  end    alias_method :terminate_start_bgs, :terminate  def terminate(*args, &block)    terminate_start_bgs(*args, &block)    RPG::BGS.last.replay  endend
Let me know if that works for you.
Untested (I don't have my VM open), but I'd recommend something like this instead:

class Scene_Menu < Scene_MenuBase alias_method :start_stop_bgs, :start def start(*args, &block) start_stop_bgs(*args, &block) Audio.bgs_stop end alias_method :terminate_start_bgs, :terminate def terminate(*args, &block) terminate_start_bgs(*args, &block) RPG::BGS.last.replay endendLet me know if that works for you.
Works fine on the main menu, but when I go to any other menu from that menu, the BGS starts back up again.

Also I am using Yanfly Engine Ace - System Options, so you might want to keep that in mind.
Of course it would -- there's an obvious problem with what I posted. Try this instead:

Code:
class Scene_Base  alias_method :start_stop_bgs, :start  def start(*args, &block)    start_stop_bgs(*args, &block)    RPG::BGS.last.replay if kind_of?(Scene_Map)    Audio.bgs_stop if kind_of?(Scene_Menu)  endend
Edit: I'm known to make stupid mistakes when I don't have RPG Maker open in front of me, but that really should do what you want now. 🙂
Of course it would -- there's an obvious problem with what I posted. Try this instead:

class Scene_Base alias_method :start_stop_bgs, :start def start(*args, &block) start_stop_bgs(*args, &block) RPG::BGS.last.replay if kind_of?(Scene_Map) Audio.bgs_stop if kind_of?(Scene_Menu) endendEdit: I'm known to make stupid mistakes when I don't have RPG Maker open in front of me, but that really should do what you want now. 🙂
Works perfectly now! Thanks a lot! 😀

Original thread: https://forums.rpgmakerweb.com/threads/stop-bgs-while-in-menu.36626/