10-02-2021, 05:42 AM
KMenuSound ACE
by Kyonides Arkanthes
by Kyonides Arkanthes
​Introduction
A board member once requested a new scriptlet that could help the game developer play a BGM on the main menu scene. It also lets you resume the previously played map BGM right where it was interrupted upon returning to the current map. This script does not alter the GUI at all so no screenshots should be provided ever!

Code:
# * KMenuSound ACE
# Scripter : Kyonides Arkanthes
# 2021-10-01
# This scriptlet will let you resume the BGM or BGS previously played on the
# current map right after exiting the menu scene. Besides the menu also features
# its very own BGM! Please feel free to set the values of KMenuSound module's
# Constants at will.
module KMenuSound
BGM = "Theme2"
VOLUME = 70
PITCH = 100
extend self
attr_accessor :bgm_pos, :bgs_pos
@bgm_pos = 0
@bgs_pos = 0
end
class Game_Map
def play_last_bgms
@map.bgm.play(KMenuSound.bgm_pos) if @map.autoplay_bgm
@map.bgs.play(KMenuSound.bgs_pos) if @map.autoplay_bgs
end
end
class Scene_Menu
include KMenuSound
alias :kyon_menusnd_scn_menu_start :start
def start
kyon_menusnd_scn_menu_start
bgm = RPG::BGM.new(BGM, VOLUME, PITCH)
bgm.play
end
end
class Scene_Map
alias :kyon_menusnd_scn_map_start2 :post_start
alias :kyon_menusnd_scn_map_call_menu :call_menu
def post_start
kyon_menusnd_scn_map_start2
$game_map.play_last_bgms
end
def call_menu
KMenuSound.bgm_pos = RPG::BGM.last.pos
KMenuSound.bgs_pos = RPG::BGS.last.pos
kyon_menusnd_scn_map_call_menu
end
end
Terms & Conditions
Feel free to use it anywhere.
Mention me in your game credits!

[End of Conditions]