Help - Search - Members - Calendar
Full Version: How do you check when an ME is playing?
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS2
steve09424
Hello!

As you know, BulletXT Audio Engine 1.2 doesn't stop the BGM temporarily when a ME is played. I was just wondering how you add a little script to it that will tell the audio engine to pause the map BGM, the play the ME, then resuming the map BGM.

Please help.
Thanks!
The Law G14
Hopefully this is what you were looking for and I'm also hoping that this is compatible with your Audio Engine:

CODE
#==============================================================================
# Title: Stop BGM When playing ME
# Version: 1.0
# Author: The Law G14
#==============================================================================

#==============================================================================
# ** Module_RPG
#------------------------------------------------------------------------------
#  A module containing RPGVX Data Structures.
#==============================================================================

module RPG
  #==========================================================================
==
  # ** Class BGM
  #==========================================================================
==
  class BGM < AudioFile
    #-------------------------------------------------------------------------
    # * Class Variables
    #-------------------------------------------------------------------------
    @@last = BGM.new
    #-------------------------------------------------------------------------
    # * Alias Listing
    #-------------------------------------------------------------------------
    alias law_bgm_stop_when_me_rpg_bgm_play play
    #-------------------------------------------------------------------------
    # * Play
    #-------------------------------------------------------------------------
    def play
      # Check if ME is valid
      if !@name.empty?
        Audio.bgm_play("Audio/BGM/" + @name, @volume, @pitch)
        @@last = "Audio/BGM/" + @name
      else
        law_bgm_stop_when_me_rpg_bgm_play
      end
    end
  end
  #==========================================================================
==
  # ** Class ME
  #==========================================================================
==
  class ME < AudioFile
    #-------------------------------------------------------------------------
    # * Alias Listing
    #-------------------------------------------------------------------------
    alias law_bgm_stop_when_me_rpg_me_play play
    #-------------------------------------------------------------------------
    # * Play
    #-------------------------------------------------------------------------
    def play
      # Check if ME is valid
      if !@name.empty?
        # If so temporarily stop currently playing BGM
        bgm = RPG::BGM.last
        Audio.bgm_stop
        # Play ME
        Audio.me_play("Audio/ME/" + @name, @volume, @pitch)
        # Then return back to original BGM
        Audio.bgm_play(bgm.to_s)
      else
        # If not, return to original method
        law_bgm_stop_when_me_rpg_me_play
      end
    end
  end
end

#==============================================================================
#
# *** END OF SCRIPT ***
#
#==============================================================================


Hope this helps smile.gif
steve09424
I get an error when an ME is played "Unable to find file #<RPG::BGM:0x2b657e0>". It could be due to the new Audio engine, and I've tried the script above and below it. I'll see if I can tinker with it a bit more so I can get it to work.

Thanks for replying!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.