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.
[VXA] Menu Use SEs

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Menu Use SEs
Version: 1.0a
Author: modern algebra
Date: January 18, 2012

Version History


  • <Version 1.0> 2012.01.18 - Fxed a small error with the RegExp
  • <Version 1.0> 2012.01.18 - Original Release

Description


This script restores the lost RMXP ability to set individual sound effects when using items and skills in the menu. This permits you to, for instance, make it so that eating food isn't the same sound effect as drinking a potion.

Features

  • Can play a unique SE on using a skill or item
  • Flexible configuration

Instructions

Paste this script into its own slot in the Script Editor, above Main but below Materials.

Script


Code: [Select]
#==============================================================================
#    Menu Use Sound Effects
#    Version: 1.0a
#    Author: modern algebra (rmrk.net)
#    Date: January 18, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script restores the lost RMXP ability to set individual sound effects
#   when using items and skills in the menu.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Insert this script into its own slot in the Script Editor, above Main but
#   below Materials.
#
#    To set up a sound effect to be played when an item or skill is used in the
#   menu, simply add the following code to the item or skill's notebox:
#
#        \menu_se["filename", v80, p100]
#          filename : the name of the SE file you are using from Audio/SE
#          v80      : the volume you want the sound to be played at. Just put
#                    v, followed immediately by the volume you want, between 0
#                    and 100. Ex: v60 would play the sound at 60% volume. If
#                    excluded, it defaults to 80.
#          p100     : the pitch to play the sound at. Just put p, followed by
#                    the pitch you want. Can be from 50 - 150. If excluded, it
#                    defaults to 100
#
#    EXAMPLES:
#
#      \menu_se["Item3", p75]
#          When the item or skill with this note is used from the menu, it will 
#         play the Item3 SE at 80 volume and 75 pitch.
#      \menu_se["Fire4"]
#          When the item or skill with this note is used from the menu, it will 
#         play the Fire4 SE at 80 volume and 100 pitch.
#      \menu_se["Thunder1", v90, p120]
#          When the item or skill with this note is used from the menu, it will 
#         play the Thunder1 SE at 90 volume and 120 pitch.
#==============================================================================

$imported ||= {}
$imported[:MA_MenuUseSE] = true

#==============================================================================
# ** RPG::UsableItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - menu_use_se
#==============================================================================

class RPG::UsableItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Menu Use SE
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mamus_menu_use_se
    if @mamus_menu_se.nil?
      if self.note[/\\MENU[_ ]SE\[(.+?)\]/im] != nil
        attrs = $1.gsub(/[\r\n]/, "")
        @mamus_menu_se = ["", 80, 100]
        @mamus_menu_se[0] = $1 if attrs.sub!(/["'](.+)['"]/, "") != nil
        @mamus_menu_se[1] = $1.to_i if attrs[/[Vv](\d+)/] != nil
        @mamus_menu_se[2] = $1.to_i if attrs[/[Pp](\d+)/] != nil
      else
        @mamus_menu_se = []
      end
    end
    @mamus_menu_se
  end
end

#==============================================================================
# ** Scene Item / Scene Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    In both, aliased method - play_se_for_item
#==============================================================================

[:Scene_Item, :Scene_Skill].each { |scene|
mamus_playitemses =
 "class #{scene}
    alias mamus_#{scene.downcase}_playitemse_2ed8 play_se_for_item
    def play_se_for_item(*args, &block)
      if !item.mamus_menu_use_se.empty?
        begin
          RPG::SE.new(*item.mamus_menu_use_se).play
        rescue
          mamus_#{scene.downcase}_playitemse_2ed8(*args, &block)
        end
      else
        mamus_#{scene.downcase}_playitemse_2ed8(*args, &block)
      end
    end
  end"
eval(mamus_playitemses)
}

Credit


  • modern algebra

Support


Please post in this topic at RMRK to report any errors or to ask any questions with regard to this script.
« Last Edit: January 31, 2013, 09:49:04 PM by modern algebra »

****
Rep:
Level 69
Another yummy script! NomNOmNom :V