Audio Settings - EJlol - 03-07-2008
Audio Settings
Version: 1.1.0
Introduction
Always wanted a volume option? With this script you can let the player change the volume. You only have to script / event a GUI for it.
Features- Change the Music volume
- Change the SE volume
Screenshots
Just turn your speakers on.
Demo
None, it's just copy-paste. And if you don't know how to copy-paste, learn it! You are the copy-paste generation after all.
Script
Code: #==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :music_volume
attr_reader :sound_volume
#------------------------------------------------------------------------
# * Alias Listings
#------------------------------------------------------------------------
unless self.method_defined?(:ejlol_as_gsystem_initialize)
alias_method :ejlol_as_gsystem_initialize, :initialize
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
ejlol_as_gsystem_initialize
@music_volume = 100
@sound_volume = 100
end
#--------------------------------------------------------------------------
# * Change backgroundmusic volume
# volume : the volume
#--------------------------------------------------------------------------
def music_volume=(volume)
@music_volume = [[volume, 100].min, 0].max
bgm_play(@playing_bgm)
end
#--------------------------------------------------------------------------
# * Change soundeffect volume
# volume : the volume
#--------------------------------------------------------------------------
def sound_volume=(volume)
@sound_volume = [[volume, 100].min, 0].max
bgs_play(@playing_bgs)
end
end
#==============================================================================
# ** Audio
#==============================================================================
module Audio
class << self
#------------------------------------------------------------------------
# * Alias Listings
#------------------------------------------------------------------------
unless self.method_defined?(:ejlol_as_audio_bgmplay)
alias_method :ejlol_as_audio_bgmplay, :bgm_play
alias_method :ejlol_as_audio_bgsplay, :bgs_play
alias_method :ejlol_as_audio_meplay, :me_play
alias_method :ejlol_as_audio_seplay, :se_play
end
#------------------------------------------------------------------------
# * BGM Play
#------------------------------------------------------------------------
def bgm_play(filename, volume = 100, pitch = 100)
volume = Integer(volume * $game_system.music_volume / 100.0)
# Original BGM Play Method
ejlol_as_audio_bgmplay(filename, volume, pitch)
end
#------------------------------------------------------------------------
# * BGS Play
#------------------------------------------------------------------------
def bgs_play(filename, volume = 80, pitch = 100)
volume = Integer(volume * $game_system.sound_volume / 100.0)
# Original BGS Play Method
ejlol_as_audio_bgsplay(filename, volume, pitch)
end
#------------------------------------------------------------------------
# * ME Play
#------------------------------------------------------------------------
def me_play(filename, volume = 100, pitch = 100)
volume = Integer(volume * $game_system.music_volume / 100.0)
# Original ME Play Method
ejlol_as_audio_meplay(filename, volume, pitch)
end
#------------------------------------------------------------------------
# * SE Play
#------------------------------------------------------------------------
def se_play(filename, volume = 80, pitch = 100)
volume = Integer(volume * $game_system.sound_volume / 100.0)
# Original SE Play Method
ejlol_as_audio_seplay(filename, volume, pitch)
end
end
end
Instructions
Copy-paste the script. You can change the volume settings with:
Code: $game_system.music_volume = 100
Code: $game_system.sound_volume = 100
Volume should be a range between 0 and 100. (The script corrects the input though.)
FAQ
None
Compatibility
Should be compatible.
Credits and Thanks
Credit: EJlol
Thanks:
Many thanks to SephirothSpawn, for helping me.
Author's Notes
I was bored.
Terms and Conditions
Give credit, no commercial use without permission from EJlol.
RE: Audio Settings - Erechel - 07-03-2012
EXCELENT! It was a pain in the ass the music volume
|