wofsauge / External-Item-Descriptions

A mod for the game "The Binding of Isaac: Rebirth" that displays useful informations for items, trinkets, rooms and more!
209 stars 121 forks source link

EID:setModIndicatorName for the very last mod loaded can be overrided #466

Open kohashiwakaba opened 2 years ago

kohashiwakaba commented 2 years ago

Sorry for no explanations, EID mod indicator updates when 'RegisterMod' is called, so EID can track which item is connected from certain mod But when the last 'RegisterMod' is called, EID does not cleanup 'current mod'(EID._currentMod). Normally, this wouldn't be the problem as most descriptions are registered on init.

The problem goes to after that. 'current mod' is still pointed at the last mod. If a certain mod updates the descriptions, or change mod indicator AFTER the init, EID changes those from the last mod, NOT original mod that called update function, which can result this: 20220519100352_1

to fix this temporarily:

For Player: Just activate this mod. No extra requirements needed.

For mod developer: Change EID._currentMod value to original mod's name before updating EID support. Not needed if the description does not change after the init

-- main.lua
wakaba = RegisterMod("Pudding and Wakaba", 1) -- Use this name for EID._currentMod

-- actual description update 
function wakaba:UpdateWakabaDescriptions()
    EID._currentMod = "Pudding and Wakaba" -- This is needed if the description updates 'AFTER' init. (like PostGameStarted)
    EID:addEntity(wakaba.INVDESC_TYPE_CURSE, -1, -1, "Curses")
    EID:setModIndicatorName("Pudding & Wakaba")
    EID:setModIndicatorIcon("Player"..wakaba.PLAYER_WAKABA.."", true)
    for cardid, carddata in pairs(wakaba.descriptions["en_us"].cards) do
        if carddata.mimiccharge then
            EID:addCardMetadata(cardid, carddata.mimiccharge, carddata.isrune)
        end
    end
end
Buurazu commented 2 years ago

I ran into this problem with adding glitched item descriptions but just made glitched items never check for mod indicator stuff I don't know the best time to wipe the current mod var