RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Different music for your menu

0 Members and 3 Guests are viewing this topic.

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Ever wanted the music to change to a set piece when you open your menu and to change back to the music that was playing on the map after you leave the menu? Well, here you go. Read the notes in the script or the notes after the script. They're the same notes but are also included in the script so you can look at them any time. Just read the notes and you shouldn't have any trouble understanding how to use the script. It was a few months ago that this was requested but I decided to repost it for use.

Code: [Select]
#-----------------------------------------------------------------
#----------------------Music in the Menu----------------------
#----------------------written by Shinami---------------------
#-----------------------------------------------------------------
#I decided to write this little script after I saw it had
#been requested on the Crankeye forums. It's really
#simple and easy to use. You just need to leave the
#quotation marks " " around your song name. If
#the name isn't the exact same as the one in your BGM
#folder, you will have problems.
#-----------------------------------------------------------------
#-------------------INCOMPATIBILITY-----------------------
#-----------------------------------------------------------------
#I havn't tested this on any other scripts outside of my own
#but since I used aliases, there should be a .01% chance
#of incompatibility. Basically, it'll only screw up when
#Hell freezes over, if you mistype the song name, or if
#you're using a CMS customly built using a different class
#name than Scene_Menu. I don't mind merging this into
#a CMS BUT you will need to post the CMS script or a
#link to the incompatible script if you want the merge to
#be done. I won't always immediately respond either
#since I do have a life outside of the internet.
#-----------------------------------------------------------------
#----------------HOW TO USE THIS SCRIPT----------------
#-----------------------------------------------------------------
#Insert the script above the script called Main and call it
#what ever you want. Afterwards, replace the text
#SONG NAME GOES HERE with the name of the music
#you want to play in the menu and it'll work just fine.
#-----------------------------------------------------------------
#------------------TOTAL TIME TAKEN----------------------
#-----------------------30 MINUTES--------------------------
#-----------------------------------------------------------------
#Also, thanks go to Blizzard for fixing a small error I
#overlooked!
#Okies...update #2 now makes it work like it was
#was intended to.
#Update #3 is to keep your background sounds from being stopped.
class Scene_Menu
 
  alias initialize_later initialize
  def initialize(menu_index = 0)
    initialize_later(menu_index = 0)
    bgm_name = "SONG NAME GOES HERE"#Name of file must match what you put here.
    bgm_volume = 0 #How loud the music plays
    bgm_pitch = 100#How fast the music plays
    $game_system.bgs_memorize
    Audio.bgs_stop
    if $game_system.playing_bgm != bgm_name
      @bgm = $game_system.playing_bgm #stores the map's music, $game_system.playing_bgm, for later use
      Audio.bgm_play("Audio/BGM/" + bgm_name, bgm_volume, bgm_pitch)#begins playing menu music
    end
  end
 
  alias update_command_later update_command
  def update_command
    update_command_later
    if Input.trigger?(Input::B) and $scene.is_a?(Scene_Map)#This checks to see if you are exiting the menu.
      #This plays the predefined cancel sound effect
      $game_system.se_play($data_system.cancel_se)
      #This tells the game to go back to the map.
      $scene = Scene_Map.new
      $game_system.bgs_restore
      $game_system.bgm_play(@bgm)#recalls the map's music, @bgm, and begins playing.
    end
  end
end

#-----------------------------------------------------------------
#----------------------Music in the Menu----------------------
#----------------------written by Shinami---------------------
#-----------------------------------------------------------------
#I decided to write this little script after I saw it had
#been requested on the Crankeye forums. It's really
#simple and easy to use. You just need to leave the
#quotation marks " " around your song name. If
#the name isn't the exact same as the one in your BGM
#folder, you will have problems.
#-----------------------------------------------------------------
#-------------------INCOMPATIBILITY-----------------------
#-----------------------------------------------------------------
#I havn't tested this on any other scripts outside of my own
#but since I used aliases, there should be a .01% chance
#of incompatibility. Basically, it'll only screw up when
#Hell freezes over, if you mistype the song name, or if
#you're using a CMS customly built using a different class
#name than Scene_Menu. I don't mind merging this into
#a CMS BUT you will need to post the CMS script or a
#link to the incompatible script if you want the merge to
#be done. I won't always immediately respond either
#since I do have a life outside of the internet.
#-----------------------------------------------------------------
#----------------HOW TO USE THIS SCRIPT----------------
#-----------------------------------------------------------------
#Insert the script above the script called Main and call it
#what ever you want. Afterwards, replace the text
#SONG NAME GOES HERE with the name of the music
#you want to play in the menu and it'll work just fine.
#-----------------------------------------------------------------
#------------------TOTAL TIME TAKEN----------------------
#-----------------------30 MINUTES--------------------------
#-----------------------------------------------------------------
#Also, thanks go to Blizzard for fixing a small error I
#overlooked!
#Okies...update #2 now makes it work like it was
#was intended to.
#Update #3 is to keep your background sounds from being stopped.
« Last Edit: February 01, 2007, 06:56:14 AM by Shinami »

**
Rep:
Level 88
Shut up and leave me alone!
Sweet I'm using it.
Hi...

********
EXA
Rep:
Level 92
Pikachu on a toilet
Project of the Month winner for April 2007
I don't mind merging this into a CMS BUT you will need to post the CMS script

No need for that, just put it under the CMS code and it should work fine with any CMS.

BTW, you have a bug. The music will end even when changing only into the Status/Equip/etc. screen.



Spoiler for Open this if you're too lazy to fix it yourself:
Change this part:

Code: [Select]
  alias update_later update
  def update
    if Input.trigger?(Input::B)
      if @status_window.active == false #This checks to see if you are exiting the menu.
        $game_system.bgm_play(@bgm)#recalls the map's music, @bgm, and begins playing.
      end
    end
    update_later
  end

Code: [Select]
  alias update_later update
  def update
    update_later
    if Input.trigger?(Input::B) and $scene.is_a?(Scene_Map)
      if @status_window.active == false #This checks to see if you are exiting the menu.
        $game_system.bgm_play(@bgm)#recalls the map's music, @bgm, and begins playing.
      end
    end
  end
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.


Get DropBox, the best free file syncing service there is!

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
*slaps hand on forehead* so thats how to do that...I tried checking $scene against scene names but it never worked. Glad to know I was close! Script has been updated so you'll need to recopy the above script and all that jazz.
« Last Edit: January 30, 2007, 12:44:45 AM by Shinami »

***
Rep:
Level 88
Uhh......I get this error, the music keeps playing after you exit...
Games in progress:
Tome of Arastovia: 7% complete at 2 hours of gametime

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Tested and fixed the bug. Sorry about that.

********
EXA
Rep:
Level 92
Pikachu on a toilet
Project of the Month winner for April 2007
*slaps hand on forehead* so thats how to do that...I tried checking $scene against scene names but it never worked. Glad to know I was close! Script has been updated so you'll need to recopy the above script and all that jazz.

Actually you can do that as well:

Code: [Select]
$scene.class == Scene_Map

But this won't work for superclasses. Here is an example:

$game_actor[2] is a Game_Actor and Game_Actor has the superclass Game_Battler. Using

Code: [Select]
$game_actor[2].class == Game_Actor

This will result in true.

Code: [Select]
$game_actor[2].is_a?(Game_Actor)

This will also result in true.

Code: [Select]
$game_actor[2].is_a?(Game_Battler)

Again the result is true.

Code: [Select]
$game_actor[2].class == Game_Battler

But this one wil result in false. See the difference?
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.


Get DropBox, the best free file syncing service there is!

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Code: [Select]
$game_actor[2].class == Game_Battler
That is false because the method class isn't in Game_Battler?


I was trying this
Code: [Select]
if $scene == Scene_Map

********
Rep:
Level 96
2011 Most Missed Member2010 Zero To Hero
Hey, instead of just turning the music OFF, can it memorize the BGM?

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
I am failing to understand what you are asking.

********
Rep:
Level 96
2011 Most Missed Member2010 Zero To Hero
Well, the BGM restarts after exiting the menu. Can it memorize the place in the BGM before switching, then replay upon the exit?

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Not without some recoding of how RMXP plays the files I would imagine. I don't know much about audio playback but I do know that the methods in Game_System didn't give an argument to restore the BGM to a set point. Although I realized another flaw in my script when double checking to make sure the above response was accurate. Currently, BGSs may not resume. I'll quickly work that in before continuing Redeye's CMS.

EDIT:Fixed the script to memorize background sounds playing when the menu is opened and to start the BGS when the menu is closed. Can't believe I didn't think of that when I wrote the script to begin with.
« Last Edit: February 01, 2007, 07:08:09 AM by Shinami »

********
EXA
Rep:
Level 92
Pikachu on a toilet
Project of the Month winner for April 2007
Well, the BGM restarts after exiting the menu. Can it memorize the place in the BGM before switching, then replay upon the exit?

This is as good as impossible in RMXP. Many have tried to make the map BGM continue from the place where it stopped after a battle, but failed. Those who actually succeeded in this (where I proudly count myself in ;D) sadly could not re-create Enterbrain's MIDI synthisizer. MP3s would loop correctly and stuff, but MIDIs were giving them a head-ache.
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.


Get DropBox, the best free file syncing service there is!