Battle/Map BGM Selector - Printable Version +- Save-Point (https://www.save-point.org) +-- Forum: Archives (https://www.save-point.org/forum-105.html) +--- Forum: Creation Asylum Archives (https://www.save-point.org/forum-90.html) +---- Forum: Scripts & Code Snippets (https://www.save-point.org/forum-92.html) +----- Forum: RPG Maker VX Code (https://www.save-point.org/forum-101.html) +----- Thread: Battle/Map BGM Selector (/thread-7034.html) |
Battle/Map BGM Selector - crazyninjaguy - 07-14-2009 Battle/Map BGM Selector - By Crazyninjaguy This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss. No support is given. If you are the owner of the thread, please contact administration. Heya! Time for me to post my second ever script! Basically, it allows you to choose your favourite Music and either play it on the map, or play it in battle. It's that simple really. The script itself is plug'n'play so all you have to do is paste it in a new script section, but i reccomend downloading the demo. Script: Script
[ruby]#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * Battle BGM Selector by Crazyninjaguy # <a href="http://www.planetdev.co.nr" target="_blank">http://www.planetdev.co.nr</a> # -------------------------------------------------------------------------- # ** Allows you to choose the battle music from the menu # -------------------------------------------------------------------------- # *** Features # -- Preview BGM before setting as battle bgm or map bgm # -- Stop playing the BGM # -- Set your favourite as the battle theme # -- Play your favourite BGM on the map # -------------------------------------------------------------------------- # *** Editable Fields # -- Lines 87-99. The names of the BGM/Music. NOT THE FILENAME! # -- Lines 174,182,190,198,206,214,222,230,238,246,254,262,270 # EXACT FILENAMES! CASE SENSITIVE! # -------------------------------------------------------------------------- # *** Notes # -- This is my second ever script so don't expect too much lol. # -- Please give credit if you use this in your game. # -- If anything goes wrong with the script then don't hesitate to PM # me on my site <a href="http://www.planetdev.co.nr" target="_blank">http://www.planetdev.co.nr</a> # -- Also if you have any ideas on how i could improve the script, # please PM me on my site <a href="http://www.planetdev.co.nr" target="_blank">http://www.planetdev.co.nr</a> #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= module Music_Selection #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * Constants #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= MUSIC_LABEL = 'Music' MENU_INDEX = 4 end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * This window simply displays text #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Window_Text < Window_Base def initialize super(0, 0, 544, 70) self.contents = Bitmap.new(width - 32, height - 32) update end def update self.contents.clear self.contents.draw_text(-50, 0, 612, 42, "Which Music Would You Prefer As The Battle Music?", 1) end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * Pop-up window showing that BGM choice was saved #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Window_Saved < Window_Base def initialize super(120, 150, 300, 100) self.contents = Bitmap.new(width - 32, height - 32) update end def update self.contents.clear self.contents.draw_text(0, 0, 268, 68, "BGM Selection Saved!", 1) end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * Space filling window #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Window_Misc < Window_Base def initialize super(272, 198, 272, 216) self.contents = Bitmap.new(width - 32, height - 32) update end def update self.contents.clear self.contents.draw_text(0, 0, 544, 416, "Badger!", 1) end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * The options for the songs #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Window_Options < Window_Selectable def initialize super(272, 70, 272, 130) @commands = ["Set As Battle BGM", "Play This Song", "Stop Playing", "Play BGM On Map"] @item_max = 4 self.contents = Bitmap.new(width - 32, height - 32) refresh end def refresh self.contents.clear for i in 0...@commands.size x = 4 y = i * 24 self.contents.draw_text(x, y, 272, 27, @commands[i]) end end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # * The main scene, nothing works without this! #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= class Scene_MusicSelect def initialize(menu_index = 0) @menu_index = menu_index end def main # Make Misc Window @window_misc = Window_Misc.new # Make Command Window @commands = [] @commands.push("Airship") @commands.push("Field1") @commands.push("Scene12") @commands.push("Ship") @commands.push("Theme3") @commands.push("Town5") @commands.push("Dungeon4") @commands.push("Battle10") @commands.push("Battle6") @commands.push("Scene4") @commands.push("Scene6") @commands.push("Scene9") @commands.push("Field3") #...etc @command_window = Window_Command.new(272,@commands) @command_window.index = @menu_index @command_window.x = 0 @command_window.y = 70 # Make Text Window @text_window = Window_Text.new # Make Options Window @options_window = Window_Options.new # 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 @text_window.dispose @options_window.dispose @window_misc.dispose end def update @command_window.update @text_window.update @options_window.update @window_misc.update # If command window is active: call update_command if @command_window.active update_command return end # If options window is active: call update_options if @options_window.active update_options return end end end def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE Sound.play_cancel # Stop playing music Audio.bgm_stop # Switch to menu screen $scene = Scene_Map.new return end # If C button was pressed if Input.trigger?(Input::C) # Play decision SE Sound.play_decision # Make options window active @command_window.active = false @options_window.active = true @options_window.index = 0 @bgm = @commands[@command_window.index] end return end def update_options # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE Sound.play_cancel # Make command window active @command_window.active = true @options_window.active = false @options_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @options_window.index when 0 # Set As Battle BGM # Play decision SE Sound.play_decision $game_system.battle_bgm = RPG::BGM.new(@bgm) Window_Saved.new Graphics.wait(60) Audio.bgm_stop $scene = Scene_Map.new when 1 # Play Song # Play decision SE Sound.play_decision Audio.bgm_play("Audio/BGM/" + @bgm, 100, 100) when 2 # Stop Playing # Play decision SE Sound.play_decision Audio.bgm_stop when 3 # Play On Map # Play decision SE Sound.play_decision Audio.bgm_play("Audio/BGM/" + @bgm, 100, 100) $scene = Scene_Map.new end return end end #============================================================================== # ** Scene_Menu #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # aliased methods - initialize, create_command_window, update_command_selection #============================================================================== class Scene_Menu < Scene_Base #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization # menu_index : command cursor's initial position #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias music_select initialize def initialize(menu_index = 0) music_select (menu_index) if @menu_index == 'Music' @menu_index = Music_Selection::MENU_INDEX elsif @menu_index >= Music_Selection::MENU_INDEX @menu_index += 1 end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Create Command Window #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias music_select_menu_cmmnd_win_create create_command_window def create_command_window music_select_menu_cmmnd_win_create c = @command_window.commands c.insert (Music_Selection::MENU_INDEX, Music_Selection::MUSIC_LABEL) width = @command_window.width @command_window.dispose @command_window = Window_Command.new(width, c) @command_window.index = @menu_index end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Update Command Selection #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias music_select_menu_cmmnd_select_upd update_command_selection def update_command_selection if @command_window.index == Music_Selection::MENU_INDEX && Input.trigger? (Input::C) # Open Music Window Sound.play_decision $scene = Scene_MusicSelect.new end return end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Update Actor Selection #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias music_select_actor_selection_upd update_actor_selection def update_actor_selection changed = false if @command_window.index > Music_Selection::MENU_INDEX @command_window.index = (@command_window.index - 1) % @command_window.commands.size changed = true end music_select_actor_selection_upd @command_window.index = (@command_window.index + 1) % @command_window.commands.size if changed end end[/ruby] Demo: http://www.mediafire.com/?sharekey=f38405d...04e75f6e8ebb871 Hope you enjoy my second ever script! Please give credit if used as it took me a while to write this ( I'm still learning :D ) |