I am back with a new pull request! Here's a new addition that goes great with "Audio.sounds": "Audio.music"!
Basically, the system for SFXs have been ported over to now include music. Below is information on how it works, along with code that will need to be added to SMBX2 itself:
Music Category IDs
1: Special Music
2: World Music
3: Level Music
Track IDs
Depending on the category ID, track IDs are the music IDs located under "music.ini".
New Functions
Audio.music[musicCategoryID][trackID]: The new table system used to get or set the music specified. Only one variable exists for the system (music). When changing music, be sure the music you want to use is a filepath string, NOT an "SDL Mixer X" music chunk made with "Audio.MusicOpen". To know how it works, see below:
To get the music, just provide the variable with the IDs set: Audio.music[musicCategoryID][trackID].music
To change the music, provide the variable with the IDs set, and then specify a filepath to the new music you're changing it to: Audio.music[musicCategoryID][trackID].music = musicFilepath
Misc.resolveMusicFile(filepathWithArguments): Like "Misc.resolveSoundFile", this function resolves a music file to see if it exists. If it returns nil, the music specified does not exist. If found, it returns the music you specified. The places that "Misc.resolveMusicFile" looks at is the following:
Level Folder (If on a level)
Episode directory
The SMBX2 root directory ("data/")
Audio.MusicCount(categoryID): Returns the number of music IDs that were applied according to what category ID you specified. In the future, this can be used for adding extra music slots to music.ini, to test to see if the count is bigger than it was before.
Audio.SfxCount(): Returns the number of sounds that were applied from sounds.ini. In the future (If this happens), this can be used for adding extra sound effect slots to sounds.ini, to test to see if the count is bigger than it was before.
SMBX2 Lua Code to Add
As for what should be added to SMBX2's Lua side for this to work, check out the codes I wrote for "main.lua" and "classexpander.lua" here: https://pastebin.com/v9tb3vGt
Conclusion
This system is useful for changing the Special Music and World Music in Lua, since changing music in those categories are either possible (World Music filepaths, but it needs extra Lua code to make it possible), or actually impossible outside of this pull request (Special Music filepaths, which can't be changed outside of editing music.ini)
So, there's the answer on how useful this will be.
Hopefully, this pull request gets accepted at some point in time!
I am back with a new pull request! Here's a new addition that goes great with "Audio.sounds": "Audio.music"!
Basically, the system for SFXs have been ported over to now include music. Below is information on how it works, along with code that will need to be added to SMBX2 itself:
Music Category IDs
Track IDs
Depending on the category ID, track IDs are the music IDs located under "music.ini".
New Functions
Audio.music[musicCategoryID][trackID].music
Audio.music[musicCategoryID][trackID].music = musicFilepath
SMBX2 Lua Code to Add
As for what should be added to SMBX2's Lua side for this to work, check out the codes I wrote for "main.lua" and "classexpander.lua" here: https://pastebin.com/v9tb3vGt
Conclusion
This system is useful for changing the Special Music and World Music in Lua, since changing music in those categories are either possible (World Music filepaths, but it needs extra Lua code to make it possible), or actually impossible outside of this pull request (Special Music filepaths, which can't be changed outside of editing music.ini)
So, there's the answer on how useful this will be.
Hopefully, this pull request gets accepted at some point in time!