The Binding of Isaac: Rebirth

The Binding of Isaac: Rebirth

Soundtrack Menu
☢ Nato Potato ☢  [developer] Jun 29, 2022 @ 7:57am
Adding a non-supported track (that doesn't interfere with other soundtracks)
If you really want to add a track that isn't supported by the menu (lets say you wanted to give sacrifice and curse rooms their own music like secret rooms, or have a unique boss fight track specifically for baby plum) you can add a bit of code to your mod so it will play as part of your soundtrack

the important part is using the SoundtrackMenuCurrentPlaylist value to check which soundtrack is currently being used, so you can make the code only run for your own soundtrack and not interfere with any others, aside from that you basically just need to check for the condition that the music should play in and whether or not it is already playing

for example
local sacrificetrack = Isaac.GetMusicIdByName("My Soundtrack Sacrifice Music") local babyplumtrack = Isaac.GetMusicIdByName("My Soundtrack Baby Plum Music") function mymod:update() --is your soundtrack the one currently being used if SoundtrackSongList and SoundtrackMenuCurrentPlaylist == "Soundtrack Name" then local room = Game():GetRoom() local music = MusicManager() --is this a curse or sacrifice room if room:GetType() == RoomType.ROOM_CURSE or room:GetType() == RoomType.ROOM_SACRIFICE then --is your music not already playing if music:GetCurrentMusicID() ~= sacrificetrack then --play music music:Play(sacrificetrack, 1) music:UpdateVolume() end SoundtrackMenuCurrentTrack = "Sacrifice Room" end --is baby plum active if room:GetBossID() == 84 and room:GetAliveBossesCount() > 0 then --is your music not already playing if music:GetCurrentMusicID() ~= babyplumtrack then --play music music:Play(babyplumtrack, 1) music:UpdateVolume() end SoundtrackMenuCurrentTrack = "Baby Plum" end end end mymod:AddCallback(ModCallbacks.MC_POST_UPDATE, mymod.update)

As long as the text in the SoundtrackMenuCurrentPlaylist check matches your soundtracks name exactly and the track titles in the GetMusicById functions match the track names in your music.xml it should work

Just keep in mind this should only really be used for single rooms, transitioning between rooms will run the usual checks for music type so if you were trying to use unsupported music for multiple connected rooms your custom music will probably restart when changing rooms.



If you wanted to have music in a custom floor introduced by a mod you also need to add your music to StageAPIs "dont override" list. e.g.
local customFloorMusic = Isaac.GetMusicIdByName("MySoundtrack CustomFloor") local musictooverride = Isaac.GetMusicIdByName("CustomFloor") function mymod:update() --is stageapi installed and enabled if StageAPI and StageAPI.Loaded then --make sure custom music is in StageAPIs 'dont override' list if StageAPI.CanOverrideMusic(customFloorMusic) then StageAPI.StopOverridingMusic(customFloorMusic) end --is your soundtrack the one currently being used if SoundtrackSongList and SoundtrackMenuCurrentPlaylist == "MySoundtrack" then local music = MusicManager() --make sure we have the right music ID for the music we want to replace if musictooverride < 1 then musictooverride = Isaac.GetMusicIdByName("CustomFloor") end --is the regular music you want to replace playing if music:GetCurrentMusicID() == musictooverride then --play custom music music:Play(customFloorMusic, 1) music:UpdateVolume() end end end end mymod:AddCallback(ModCallbacks.MC_POST_UPDATE, mymod.update)
Last edited by ☢ Nato Potato ☢; Feb 19 @ 11:38pm
< >
Showing 1-1 of 1 comments
Flabort Aug 31, 2024 @ 11:25pm 
I don't want this getting lost in the unfiltered comments. I'm going to quote it here:

Originally posted by flabort:
Nato Potato, can you elaborate on your answer to wookywok11 and what you mean when there's an option for how to handle StageAPI floor music?

So if someone is making a mod to use Soundtrack Menu, and wanted to use their own music for Fiend Folio, for instance. Would they add something to the music.XML,
IE <track name="myMod FiendFolioBossOverJingle" track="I Killed A Boss.ogg" loop="false" />
or would they have to do it with Lua via the non-supported track discussion?
Originally posted by nato potato:
There's a couple ways to do that, simplest is to have your soundtrack mod later in the mod load order and just replace the audio files by having their filename and folder name the same as the custom floors music (a couple soundtrack mods out there already do this) the problem with that is it will just always override the music and doesn't care about the current soundtrack setting

better but more complicated way is to have an XML entry in your soundtrack for the music and then a bit of lua to add your music to the stageAPIs "dont override" list, and also some stuff similar to the "non-supported" discussion code you mentioned, basically check if A. you are in the specific custom floor, B. your soundtrack is currently selected, C. your music isn't already playing, and D. should your music be played (i.e. if its boss fight music check if you're in an uncleared boss room), then replace with your music.
Originally posted by flabort:
I appreciate the answer, but me and another concerned party are not terribly familiar with Lua. It looks like it forgoes brackets, and uses "end" to indicate the end of an if statement or loop? Or is it like python and whitespace matters too?

So if for example we wanted to override the fiend folio track "LabTheme" in our Soundtrack using the second method, would our XML name just be "LabTheme", or "MyMod LabTheme"? Clearly using the first method, it would just be "LabTheme", but we would have to change our root or have a second <music> element, right? And I'm a little lost with the adding the music to stageAPIs "don't overrride" list as well.

Any chance we could get a code example for the second method?

Edit: (An example was added in the OP)
Last edited by Flabort; Oct 17, 2024 @ 9:48pm
< >
Showing 1-1 of 1 comments
Per page: 1530 50