Jesse66126 4 Report post Posted October 31, 2012 (edited) It seems really easy. I know how to play music via a script, but how would you get it to play a certain song every time the menu is opened, and then revert to the map BGM when the menu is closed? Edited October 31, 2012 by Jesse66126 Share this post Link to post Share on other sites
0 Moonpearl 32 Report post Posted October 31, 2012 Put the play music command at the beginning of Scene_Menu's main method, and have it stop or fade at the end of that same method. The map music should return automatically. Share this post Link to post Share on other sites
0 diagostimo 11 Report post Posted October 31, 2012 (edited) its pretty simple, look into the main proccess of your scene "def main", here you will see a load of code get initialized up top, then somewhere central you will see the loop proccess that keeps the scene active: loop do Graphics.update Input.update update if $scene != self break end end then just below the loop you will see all the objects get disposed, so basicly it stays in the loop when the scene is active, then when it changes the loop breaks and continues to dispose, basicly you want to change the music before the loop for your menu music, then after it to change the music back to the maps music you can use this script snippet: $game_map.autoplay Edited October 31, 2012 by diagostimo Share this post Link to post Share on other sites
0 Moonpearl 32 Report post Posted October 31, 2012 its pretty simple, look into the main proccess of your scene "def update", This is main, not update. Share this post Link to post Share on other sites
0 diagostimo 11 Report post Posted October 31, 2012 This is main, not update. oops typo, and looks like you beat me to it :P Share this post Link to post Share on other sites
0 Jesse66126 4 Report post Posted October 31, 2012 so how would it look in a script? Share this post Link to post Share on other sites
0 diagostimo 11 Report post Posted October 31, 2012 class Scene_Menu def main #INITIALIZE YOUR MUSIC Audio.bgm_play("Audio/BGM/" + NAME, VOL, PITCH) #THEN EVERTHING ELSE # #THEN AFTER EVERYTHING ELSE WRITE THE CODE TO END THE MUSIC Audio.bgm_stop #will autoplay any autoplay music set for the map $game_map.autoplay end end also if your map has bgs playing you can use: Audio.bgs_stop at the begining to stop it Share this post Link to post Share on other sites
0 Jesse66126 4 Report post Posted October 31, 2012 Ok, it starts but doesn't stop. #============================================================================== # ** Scene_Menu #------------------------------------------------------------------------------ # This class performs menu screen processing. #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # * Object Initialization # menu_index : command cursor's initial position #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main Audio.bgm_play("Audio/BGM/" + "LD", 100, 0) # Make command window s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "Status" s5 = "Save" s6 = "Shut Down" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6]) @command_window.index = @menu_index # If number of party members is 0 if $game_party.actors.size == 0 # Disable items, skills, equipment, and status @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) end # If save is forbidden if $game_system.save_disabled # Disable save @command_window.disable_item(4) end # Make play time window @playtime_window = Window_PlayTime.new @playtime_window.x = 0 @playtime_window.y = 224 # Make steps window @steps_window = Window_Steps.new @steps_window.x = 0 @steps_window.y = 320 # Make gold window @gold_window = Window_Gold.new @gold_window.x = 0 @gold_window.y = 416 # Make status window @status_window = Window_MenuStatus.new @status_window.x = 160 @status_window.y = 0 # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @command_window.dispose @playtime_window.dispose @steps_window.dispose @gold_window.dispose @status_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows @command_window.update @playtime_window.update @steps_window.update @gold_window.update @status_window.update # If command window is active: call update_command if @command_window.active update_command return end # If status window is active: call update_status if @status_window.active update_status return end end #-------------------------------------------------------------------------- # * Frame Update (when command window is active) #-------------------------------------------------------------------------- def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to map screen $scene = Scene_Map.new return end # If C button was pressed if Input.trigger?(Input::C) # If command other than save or end game, and party members = 0 if $game_party.actors.size == 0 and @command_window.index < 4 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Branch by command window cursor position case @command_window.index when 0 # item # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to item screen $scene = Scene_Item.new when 1 # skill # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active $scene = Scene_Hero_DataBase.new when 4 # save # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to save screen $scene = Scene_Save.new when 5 # end game # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to end game screen $scene = Scene_End.new end return end end #-------------------------------------------------------------------------- # * Frame Update (when status window is active) #-------------------------------------------------------------------------- def update_status # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Make command window active @command_window.active = true @status_window.active = false @status_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 1 # skill # If this actor's action limit is 2 or more if $game_party.actors[@status_window.index].restriction >= 2 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to skill screen $scene = Scene_Skill.new(@status_window.index) when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to equipment screen $scene = Scene_Equip.new(@status_window.index) when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to status screen $scene = Scene_Status.new(@status_window.index) end return end Audio.bgm_stop #will autoplay any autoplay music set for the map $game_map.autoplay end end Share this post Link to post Share on other sites
0 diagostimo 11 Report post Posted October 31, 2012 you added Audio.bgm_stop and $game_map.autoplay to the update_status method, they should be at the end of the main method: class Scene_Menu def main #start audio #everything else #end audio end #this is another method def update #whatever update does end end all you need to look at is the indenting of the end's, every method has an end that is inline with it just make sure you put your Audio stoping code above the main's end Share this post Link to post Share on other sites
0 Jesse66126 4 Report post Posted October 31, 2012 something like this? It's still not stopping and refreshing the map music. #============================================================================== # ** Scene_Menu #------------------------------------------------------------------------------ # This class performs menu screen processing. #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # * Object Initialization # menu_index : command cursor's initial position #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main Audio.bgm_play("Audio/BGM/" + "LD", 100, 0) # Make command window s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "Status" s5 = "Save" s6 = "Shut Down" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6]) @command_window.index = @menu_index # If number of party members is 0 if $game_party.actors.size == 0 # Disable items, skills, equipment, and status @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) end # If save is forbidden if $game_system.save_disabled # Disable save @command_window.disable_item(4) end # Make play time window @playtime_window = Window_PlayTime.new @playtime_window.x = 0 @playtime_window.y = 224 # Make steps window @steps_window = Window_Steps.new @steps_window.x = 0 @steps_window.y = 320 # Make gold window @gold_window = Window_Gold.new @gold_window.x = 0 @gold_window.y = 416 # Make status window @status_window = Window_MenuStatus.new @status_window.x = 160 @status_window.y = 0 # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @command_window.dispose @playtime_window.dispose @steps_window.dispose @gold_window.dispose @status_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows @command_window.update @playtime_window.update @steps_window.update @gold_window.update @status_window.update # If command window is active: call update_command if @command_window.active update_command return end # If status window is active: call update_status if @status_window.active update_status return end end #-------------------------------------------------------------------------- # * Frame Update (when command window is active) #-------------------------------------------------------------------------- def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to map screen $scene = Scene_Map.new return end # If C button was pressed if Input.trigger?(Input::C) # If command other than save or end game, and party members = 0 if $game_party.actors.size == 0 and @command_window.index < 4 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Branch by command window cursor position case @command_window.index when 0 # item # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to item screen $scene = Scene_Item.new when 1 # skill # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active $scene = Scene_Hero_DataBase.new when 4 # save # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to save screen $scene = Scene_Save.new when 5 # end game # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to end game screen $scene = Scene_End.new end return end end #-------------------------------------------------------------------------- # * Frame Update (when status window is active) #-------------------------------------------------------------------------- def update_status # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Make command window active @command_window.active = true @status_window.active = false @status_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 1 # skill # If this actor's action limit is 2 or more if $game_party.actors[@status_window.index].restriction >= 2 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to skill screen $scene = Scene_Skill.new(@status_window.index) when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to equipment screen $scene = Scene_Equip.new(@status_window.index) when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to status screen $scene = Scene_Status.new(@status_window.index) end return end def update Audio.bgm_stop #will autoplay any autoplay music set for the map $game_map.autoplay end end end Share this post Link to post Share on other sites
0 diagostimo 11 Report post Posted October 31, 2012 no, the only thing you should edit is main with the audio starting at the top and ending at the bottom of the same method like this: #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main Audio.bgm_play("Audio/BGM/" + "LD", 100, 0) Audio.bgs_stop # Make command window s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "Status" s5 = "Save" s6 = "Shut Down" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6]) @command_window.index = @menu_index # If number of party members is 0 if $game_party.actors.size == 0 # Disable items, skills, equipment, and status @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) end # If save is forbidden if $game_system.save_disabled # Disable save @command_window.disable_item(4) end # Make play time window @playtime_window = Window_PlayTime.new @playtime_window.x = 0 @playtime_window.y = 224 # Make steps window @steps_window = Window_Steps.new @steps_window.x = 0 @steps_window.y = 320 # Make gold window @gold_window = Window_Gold.new @gold_window.x = 0 @gold_window.y = 416 # Make status window @status_window = Window_MenuStatus.new @status_window.x = 160 @status_window.y = 0 # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @command_window.dispose @playtime_window.dispose @steps_window.dispose @gold_window.dispose @status_window.dispose Audio.bgm_stop $game_map.autoplay end just replace main with that, if you look i added bgs_stop at the start, that ensure the bgs doesnt carry over from the map, unless you want it to Share this post Link to post Share on other sites
0 Jesse66126 4 Report post Posted October 31, 2012 (edited) It works! Thank you! Err...For some reason it changes to the map music whenever you go to the status, skill, items, save screens etc. OK, just had to make a small tweak when the music is supposed to actually stop. This is a custom menu with music, and it uses the Battler Graphic instead of default. If anyone wants to use it as well. Thanks to diagostimo and Moonpearl for their help. =) #============================================================================== # ** Scene_Menu #------------------------------------------------------------------------------ # This class performs menu screen processing. #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # * Object Initialization # menu_index : command cursor's initial position #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main Audio.bgm_play("Audio/BGM/" + "LD", 100, 0) Audio.bgs_stop # Make command window s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "Status" s5 = "Save" s6 = "Shut Down" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6]) @command_window.index = @menu_index # If number of party members is 0 if $game_party.actors.size == 0 # Disable items, skills, equipment, and status @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) end # If save is forbidden if $game_system.save_disabled # Disable save @command_window.disable_item(4) end # Make play time window @playtime_window = Window_PlayTime.new @playtime_window.x = 0 @playtime_window.y = 224 # Make steps window @steps_window = Window_Steps.new @steps_window.x = 0 @steps_window.y = 320 # Make gold window @gold_window = Window_Gold.new @gold_window.x = 0 @gold_window.y = 416 # Make status window @status_window = Window_MenuStatus.new @status_window.x = 160 @status_window.y = 0 # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @command_window.dispose @playtime_window.dispose @steps_window.dispose @gold_window.dispose @status_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows @command_window.update @playtime_window.update @steps_window.update @gold_window.update @status_window.update # If command window is active: call update_command if @command_window.active update_command return end # If status window is active: call update_status if @status_window.active update_status return end end #-------------------------------------------------------------------------- # * Frame Update (when command window is active) #-------------------------------------------------------------------------- def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to map screen Audio.bgm_stop $game_map.autoplay $scene = Scene_Map.new return end # If C button was pressed if Input.trigger?(Input::C) # If command other than save or end game, and party members = 0 if $game_party.actors.size == 0 and @command_window.index < 4 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Branch by command window cursor position case @command_window.index when 0 # item # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to item screen $scene = Scene_Item.new when 1 # skill # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 4 # save # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to save screen $scene = Scene_Status.new(@status_window.index) when 5 # end game # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to end game screen $scene = Scene_End.new end return end end #-------------------------------------------------------------------------- # * Frame Update (when status window is active) #-------------------------------------------------------------------------- def update_status # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Make command window active @command_window.active = true @status_window.active = false @status_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 1 # skill # If this actor's action limit is 2 or more if $game_party.actors[@status_window.index].restriction >= 2 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to skill screen $scene = Scene_Skill.new(@status_window.index) when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to equipment screen $scene = Scene_Equip.new(@status_window.index) when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to status screen $scene = Scene_Status.new(@status_window.index) end return end end end Edited October 31, 2012 by Jesse66126 Share this post Link to post Share on other sites
0 diagostimo 11 Report post Posted October 31, 2012 ye you added that right, if you wanted to actually save going through all the code you could do this: class Scene_Menu alias main_copy main def main #start your audio main_copy if $scene.is_a?(Scene_Map) #stop your audio end end end basicly the alias copies the method defined, then we can use that object to call the old method as you can see how i implemented it, also i put a conditional check to test if the scene is a map when the script closes, that will eliminate you having to edit the input b part in the update method, so the music will only stop and revert if the new target scene is a map, with that script you would just place it below all other scripts/or your menu script :) Share this post Link to post Share on other sites
0 Moonpearl 32 Report post Posted November 1, 2012 if $scene.is_a?(Scene_Map) #stop your audio end The condition in this part is useless, the script won't access it unless the scene is being exited anyways. So, just the same without the "if". Share this post Link to post Share on other sites
0 diagostimo 11 Report post Posted November 1, 2012 its not useless, if you look at his previous post he mentioned the music stopped when entering a sub menu, that condition handles whever it should stop or not depending on the new scene Share this post Link to post Share on other sites
0 Moonpearl 32 Report post Posted November 1, 2012 Right, sorry. Share this post Link to post Share on other sites
It seems really easy. I know how to play music via a script, but how would you get it to play a certain song every time the menu is opened, and then revert to the map BGM when the menu is closed?
Edited by Jesse66126Share this post
Link to post
Share on other sites