CSCA- Menu Music Modification

Ive been trying to modify CSCA's Menu Music to change up whats playing depending on a variable which is 96. I tried to modify myself but kept running into crashes, heres my attempted rework:
Spoiler: Code
=begin
CSCA Menu Theme
version: 1.2 (Released: July 24, 2012)
Created by: Casper Gaming (https://www.caspergaming.com/)

Compatibility:
Made for RPGVXAce
IMPORTANT: ALL CSCA Scripts should be compatible with each other unless
otherwise noted.

Version History:
Version 1.0
-Original Script

Version 1.1
-Fixed menu theme not going away after common event attached to item/skill used.

Version 1.2
-Fixed wrong music playback after menu close.

FFEATURES:
This script will play a specific BGM in the main menu and other scenes called
from the main menu.

SETUP
This script requires setup further down.
Instructions included below.

CREDIT and TERMS:
Please visit https://www.caspergaming.com/terms-of-use/ for terms of use and
credit guidelines
=end
module CSCA_MENUTHEME
$game_variables[96] = {
0 => MUSIC = "snowy"
1 => MUSIC = "lotus"
}




# MUSIC = "snowy" # BGM track that is played during the menu screens.

end # END SETUP. Don't touch this or anything below.
class Scene_Menu < Scene_MenuBase

alias csca_menutheme_start start
def start
csca_menutheme_start
csca_save_map_music
end

alias csca_menutheme_terminate terminate
def terminate
csca_menutheme_terminate
$game_map.csca_replay_bgm_and_bgs if SceneManager.scene_is?(Scene_Map)
end

def csca_save_map_music
$game_map.csca_save_music
csca_play_menu_theme
end

def csca_play_menu_theme
Audio.bgm_play("Audio/BGM/" + CSCA_MENUTHEME::[$game_variables[96]], 50, 100)
RPG::BGS.stop
end

end
class Game_Map

def csca_save_music
@csca_map_bgm = RPG::BGM.last
@csca_map_bgs = RPG::BGS.last
end

def csca_replay_bgm_and_bgs
@csca_map_bgm.replay if !@csca_map_bgm.nil?
@csca_map_bgs.replay if !@csca_map_bgs.nil?
end

end
class Scene_ItemBase < Scene_MenuBase
alias csca_music_stop check_common_event
def check_common_event
$game_map.csca_replay_bgm_and_bgs if $game_temp.common_event_reserved?
csca_music_stop
end
end
Here is the original code. If someone can help me out and (possibly, don't have to) explain what I was doing wrong, I would appreciate it.
Spoiler: Code
=begin
CSCA Menu Theme
version: 1.2 (Released: July 24, 2012)
Created by: Casper Gaming (https://www.caspergaming.com/)

Compatibility:
Made for RPGVXAce
IMPORTANT: ALL CSCA Scripts should be compatible with each other unless
otherwise noted.

Version History:
Version 1.0
-Original Script

Version 1.1
-Fixed menu theme not going away after common event attached to item/skill used.

Version 1.2
-Fixed wrong music playback after menu close.

FFEATURES:
This script will play a specific BGM in the main menu and other scenes called
from the main menu.

SETUP
This script requires setup further down.
Instructions included below.

CREDIT and TERMS:
Please visit https://www.caspergaming.com/terms-of-use/ for terms of use and
credit guidelines
=end
module CSCA_MENUTHEME

MUSIC = "snowy" # BGM track that is played during the menu screens.

end # END SETUP. Don't touch this or anything below.
class Scene_Menu < Scene_MenuBase

alias csca_menutheme_start start
def start
csca_menutheme_start
csca_save_map_music
end

alias csca_menutheme_terminate terminate
def terminate
csca_menutheme_terminate
$game_map.csca_replay_bgm_and_bgs if SceneManager.scene_is?(Scene_Map)
end

def csca_save_map_music
$game_map.csca_save_music
csca_play_menu_theme
end

def csca_play_menu_theme
Audio.bgm_play("Audio/BGM/" + CSCA_MENUTHEME::MUSIC, 50, 100)
RPG::BGS.stop
end

end
class Game_Map

def csca_save_music
@csca_map_bgm = RPG::BGM.last
@csca_map_bgs = RPG::BGS.last
end

def csca_replay_bgm_and_bgs
@csca_map_bgm.replay if !@csca_map_bgm.nil?
@csca_map_bgs.replay if !@csca_map_bgs.nil?
end

end
class Scene_ItemBase < Scene_MenuBase
alias csca_music_stop check_common_event
def check_common_event
$game_map.csca_replay_bgm_and_bgs if $game_temp.common_event_reserved?
csca_music_stop
end
end
I don't get the the code, but it still target the common event used?
however variables used, you used an object, and that is not readed.

why not make the list inside the common event and read the variables there?

so if variable 93 == 0
play menu music (as default)
end
if variable 93 == 1
play snowy
end

and continue the list there (set this a parallel or action trigger to run once.
depending how you change it and where 🙂

if on the map itself, call common event there and it should work.
(possibly, don't have to) explain what I was doing wrong, I would appreciate it.
You don't define hash the way you were doing and you do not assign data to a variable inside a module.

You simply make two small changes (and then you assign the value in the variale)

MUSIC = 96 # the variable that will hold the music track name.

Audio.bgm_play("Audio/BGM/" + $game_variables[CSCA_MENUTHEME::MUSIC], 100, 100)

then when the game starts you assign the value to the variable.
Variables don't have to be just numbers.
Use the script part of the variable event command to assign it the value of "Field2"
You don't define hash the way you were doing and you do not assign data to a variable inside a module.

You simply make two small changes (and then you assign the value in the variale)

MUSIC = 96 # the variable that will hold the music track name.

Audio.bgm_play("Audio/BGM/" + $game_variables[CSCA_MENUTHEME::MUSIC], 100, 100)

then when the game starts you assign the value to the variable.
Variables don't have to be just numbers.
Use the script part of the variable event command to assign it the value of "Field2"
I was able to do this, but it needed one more thing.
at the end of $game_variables[CSCA_MENUTHEME::MUSIC] it needed a ".to_s" added.
so fully it would look like this
Audio.bgm_play("Audio/BGM/" + $game_variables[CSCA_MENUTHEME::MUSIC].to_s, 100, 100)
it needed a ".to_s" added.
That would be if you didn't put the value into the variable correctly.
If it was "field2" with the quotes then it would save it as a string so the to_s would not be needed.
It would be interesting to see that it doesn't work.
That would be if you didn't put the value into the variable correctly.
If it was "field2" with the quotes then it would save it as a string so the to_s would not be needed.
It would be interesting to see that it doesn't work.
Heres how I wrote it up with my friend’s modification addition.
Spoiler: CSCA Menu Music Modification
module CSCA_MENUTHEME

MUSIC = 96 # "snowy" # BGM track that is played during the menu screens.

end # END SETUP. Don't touch this or anything below.
class Scene_Menu < Scene_MenuBase

alias csca_menutheme_start start
def start
csca_menutheme_start
csca_save_map_music
end

alias csca_menutheme_terminate terminate
def terminate
csca_menutheme_terminate
$game_map.csca_replay_bgm_and_bgs if SceneManager.scene_is?(Scene_Map)
end

def csca_save_map_music
$game_map.csca_save_music
csca_play_menu_theme
end

def csca_play_menu_theme
Audio.bgm_play("Audio/BGM/" + "Menu" + $game_variables[CSCA_MENUTHEME::MUSIC].to_s, 50, 100)
RPG::BGS.stop
end

end
class Game_Map

def csca_save_music
@csca_map_bgm = RPG::BGM.last
@csca_map_bgs = RPG::BGS.last
end

def csca_replay_bgm_and_bgs
@csca_map_bgm.replay if !@csca_map_bgm.nil?
@csca_map_bgs.replay if !@csca_map_bgs.nil?
end

end
class Scene_ItemBase < Scene_MenuBase
alias csca_music_stop check_common_event
def check_common_event
$game_map.csca_replay_bgm_and_bgs if $game_temp.common_event_reserved?
csca_music_stop
end
end
I got this error before I added the .to_s to it
So unless I misunderstood what you told me to do and I did something wrong. I managed to get a fix for it.
Audio.bgm_play("Audio/BGM/" + "Menu"
This is why. You are specifying the file name as "Menu" and adding a number.
So you are using the variable to save numbers.
Variables can do a whole lot more.
1744238996638.png

1744239071523.png

1744238974999.png

1744239033203.png
This is why. You are specifying the file name as "Menu" and adding a number.
So you are using the variable to save numbers.
Variables can do a whole lot more.
View attachment 337044
View attachment 337046
View attachment 337043
View attachment 337045
Well then, the more I know lol.
Appreciate it

Original thread: https://forums.rpgmakerweb.com/threads/csca-menu-music-modification.176781/