Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if mod file exists #515

Open
BryanHaley opened this issue Nov 23, 2024 · 0 comments
Open

Check if mod file exists #515

BryanHaley opened this issue Nov 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@BryanHaley
Copy link

BryanHaley commented Nov 23, 2024

Sorry for the issue spam; should be the last one related to the mod I'm working on.

My mod does something like this:

audioStream = nil

if (seqID == SEQ_EVENT_CUTSCENE_COLLECT_STAR) then
    audioStream = audio_stream_load("SEQ_EVENT_CUTSCENE_COLLECT_STAR.mp3");
elseif (seqID == SEQ_MENU_TITLE_SCREEN) then
    audioStream = audio_stream_load("SEQ_MENU_TITLE_SCREEN.mp3");
...
end

if (audioStream) then
    audio_stream_set_looping(audioStream, true);
    audio_stream_play(audioStream, true, 1);
else
    -- No override available. Play the SM64 music.
    return seqID;
end

With the idea being that users can drop in a SEQ_EVENT_CUTSCENE_COLLECT_STAR.mp3 or SEQ_MENU_TITLE_SCREEN.mp3 file and the SM64 Midi sequence will be overridden with the mp3 file if it exists. If the override doesn't exist, audioStream returns nil, and the original Midi sequence is returned.

This works as-is currently, but it does result in a Your script has errors! pop-up when an override doesn't exist, as the audio_stream_load reports an error if the file is not found. I think the cleanest way to address this would be if I could do something like:

audioStream = nil
if (
    seqID == SEQ_EVENT_CUTSCENE_COLLECT_STAR &&
    mod_file_exists("sound/SEQ_EVENT_CUTSCENE_COLLECT_STAR.mp3")
) then
...

but as far as I can tell there isn't a function quite like that.

@AgentXLP AgentXLP added the enhancement New feature or request label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants