TeamREPENTOGON / TeamREPENTOGON/REPENTOGON

returning a value in a MC_PRE_MUSIC_PLAY, MC_PRE_MUSIC_PLAY_JINGLE or MC_PRE_SFX_PLAY function prevents execution of other similar callbacks

Open
#798 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
345
Forks
51
Avg merge
11h 2m
Merged PRs (30d)
4

Description

if a mod uses a MC_PRE_MUSIC_PLAY, MC_PRE_MUSIC_PLAY_JINGLE or MC_PRE_SFX_PLAY function that returns a value any other mods that use those callbacks fail to run their functions (makes sense when returning false but wasn't expecting other return values to do this)

e.g. with this code only the top 3 functions get executed

function mod:prejingle(id)
    Isaac.ConsoleOutput(id .. "j1\n")
    return id+1
end
mod:AddCallback(ModCallbacks.MC_PRE_MUSIC_PLAY_JINGLE, mod.prejingle)
function mod:premusic(id)
    Isaac.ConsoleOutput(id .. "m1\n")
    return id+2
end
mod:AddCallback(ModCallbacks.MC_PRE_MUSIC_PLAY, mod.premusic)
function mod:presfx(id, Volume, Delay, Loop, Pitch, Pan)
    Isaac.ConsoleOutput(id .. "s1\n")
    return {id+3, Volume, Delay, Loop, Pitch, Pan}
end
mod:AddCallback(ModCallbacks.MC_PRE_SFX_PLAY, mod.presfx)

function mod:prejingle2(id)
    Isaac.ConsoleOutput(id .. "j2\n")
    return id+4
end
mod:AddCallback(ModCallbacks.MC_PRE_MUSIC_PLAY_JINGLE, mod.prejingle2)
function mod:premusic2(id)
    Isaac.ConsoleOutput(id .. "m2\n")
    return id+5
end
mod:AddCallback(ModCallbacks.MC_PRE_MUSIC_PLAY, mod.premusic2)
function mod:presfx2(id, Volume, Delay, Loop, Pitch, Pan)
    Isaac.ConsoleOutput(id .. "s2\n")
    return {id+6, Volume, Delay, Loop, Pitch, Pan}
end
mod:AddCallback(ModCallbacks.MC_PRE_SFX_PLAY, mod.presfx2)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace the dispatch paths for MC_PRE_MUSIC_PLAY, MC_PRE_MUSIC_PLAY_JINGLE, and MC_PRE_SFX_PLAY, starting with the callback handling used by the script extender. Reproduce the supplied Lua callbacks and determine how returned values affect subsequent callbacks. Done means multiple registered callbacks execute while the existing return-value behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.