LAWS Menu Music

LAWS Menu Music

Version 2.0
The Law G14/TheScripter
10/11/09


Introduction

I already had this script over at RRR but I decided to bring it here as well. I saw a script like this before for vx by Sojabird and since I noticed that a lot of people seemed to like it, I made one for xp. Basically what it does is play a different music then the map music when you enter the menu. Hope you guys like it :)


Features

- Plays music in menu

- Plug n’ Play

- Can choose if you would like the BGM to be just the Map BGM except faded out a little (In Version 2.0)


Script


Script Spoiler
  1. #------------------------------------------------------------------------------
  2. #==============================================================================
  3. #==============================================================================
  4. #=========================*Law's Menu Music*===================================
  5. #=========================Author: The Law G14==================================
  6. #===================Original VX script by Sojabird=============================
  7. #=======================Bug fixes by Night Runner==============================
  8. #============================Version 2.0=======================================
  9. #==============================================================================
  10. #------------------------------------------------------------------------------
  11.  
  12. #==============================================================================
  13. # ** Music_Custom [CUSTOMIZATION WITHIN THIS MODULE]
  14. #------------------------------------------------------------------------------
  15. #  This module contains the main customization within the script
  16. #==============================================================================
  17.  
  18. module Music_Custom
  19.  
  20.   # Fade Map Music (If true, the menu music will be a softer verision of the
  21.   # map music
  22.   Fade_Map_BGM = true
  23.  
  24.   # Set the file of the BGM for the Menu Music
  25.   File = "Audio/BGM/001-Battle01"
  26.  
  27. end
  28.  
  29. #===============================================================================
  30. # ** Scene_Menu
  31. #-------------------------------------------------------------------------------
  32. # This class performs menu screen processing.
  33. #===============================================================================
  34.  
  35. class Scene_Menu
  36.   #--------------------------------------------------------------------------
  37.   # * Alias Listing
  38.   #--------------------------------------------------------------------------
  39.   alias law_music_scene_menu_initialize   initialize  
  40.   alias law_music_scene_menu_main         main        
  41.   #--------------------------------------------------------------------------
  42.   # * Object Initialization
  43.   #--------------------------------------------------------------------------  
  44.   def initialize(*args)
  45.     if Music_Custom::Fade_Map_BGM
  46.       # Dim down volume of bgm when entering menu
  47.       $game_system.playing_bgm.volume = 50
  48.       $game_system.bgm_play($game_system.bgm_memorize)
  49.     else
  50.       Audio.bgm_play(Music_Custom::File, 100, 100)
  51.     end
  52.     # Call original method
  53.     return law_music_scene_menu_initialize(*args)
  54.   end
  55.   #-----------------------------------------------------------------------------
  56.   # * Main
  57.   #-----------------------------------------------------------------------------
  58.   def main
  59.     # Call original method
  60.     law_music_scene_menu_main
  61.     if Music_Custom::Fade_Map_BGM
  62.       # If scene is equal to default, restore bgm to original method
  63.       $game_system.playing_bgm.volume = 100 if $scene.is_a?(Scene_Map)
  64.       $game_system.bgm_play($game_system.bgm_memorize)
  65.     else
  66.       $game_system.bgm_restore if $scene.is_a? Scene_Map
  67.     end
  68.   end
  69. end
  70.  
  71.  
  72. #===============================================================================
  73. # ** Scene_Item
  74. #-------------------------------------------------------------------------------
  75. #  This class performs item screen processing.
  76. #===============================================================================
  77.  
  78. class Scene_Item
  79.   #--------------------------------------------------------------------------
  80.   # * Alias Listing
  81.   #--------------------------------------------------------------------------
  82.   alias law_music_scene_item_main         main  
  83.   #-----------------------------------------------------------------------------
  84.   # * Update Command
  85.   #-----------------------------------------------------------------------------
  86.   def main
  87.     # Call original method
  88.     law_music_scene_item_main
  89.     if Music_Custom::Fade_Map_BGM
  90.       # If scene is back to map, restore volume to default
  91.       $game_system.playing_bgm.volume = 100 if $scene.is_a?(Scene_Map)
  92.       $game_system.bgm_play($game_system.bgm_memorize)
  93.     else
  94.       $game_system.bgm_restore if $scene.is_a? Scene_Map
  95.     end
  96.   end
  97. end
Expand to see the code.



Compatibility

Will probably run into issues with scripts that edit the menu.


Installation

Customize your script at the top.


FAQ

None as of now.


Terms and Conditions

Please credit me where it is due.



Special Thanks

Special Thanks to Sojabird and his script for giving me the idea to do this script.

Thanks to Night Runner for Bug fixes as well as Redd for suggesting the idea on the faded Map BGM
Simple little script, but quite useful! I like it. Ain't much to comment on, which is a good thing. Normally I would say, make a method for restoring BGM (upon reentering Scene_Map) since you wrote the same lines twice for Scene_Menu and Scene_Item, but it's so small it doesn't really matter.
Yea I could do that to improve readibility or something and to eliminate more than one instance of a block of code, but like you said it's so small it wouldn't really make much of a difference. Thanks for the comment and I'm glad you find it useful!

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75125