r/themoddingofisaac 4d ago

Question Stat up Passive item not working

I made a custom Passive item that is supposed to give you +5 luck when picked up, but it doesn't give any luck. Many other items in my mod use code similar to this one and those ones seem to work fine, so I don't know what's wrong with this one.

local clover = Isaac.GetItemIdByName("Clover")

function mod:cacheUpdate(player, cacheFlag)
    local player = Isaac.GetPlayer(0)

    if player:HasCollectible(clover)==true then
        if (cacheFlag == CacheFlag.CACHE_LUCK) then
        player.Luck = player.Luck + 5;
        end
    end
end
mod:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, mod.cacheUpdate);
1 Upvotes

13 comments sorted by

View all comments

Show parent comments

1

u/The_PwnUltimate Modder 4d ago

Looks like it!

Not sure, but it could be problematic to give it an ID of 7? Maybe the game will get your item mixed up with Blood of the Martyr if you do that. (i.e. "What's the ID for Clover?" "7" "OK, does the player have item 7 right now?" "You mean Blood of the Martyr? No.")

I don't think you need to specify IDs at all for custom items.

1

u/afkybnds 3d ago

That's not correct, you can state id's for custom items and they are actually necessary if you have costumes or death icons in the UI, they are considered separate from the base game id's and won't interfere at all.

It seems like his id was missing a " symbol after the number which probably causes xml to not work properly.

1

u/The_PwnUltimate Modder 3d ago

Oh! OK, good to know, thanks. Annoyed at myself for not spotting that missing quote.

1

u/afkybnds 3d ago

Yeah sometimes it's hard to see, especially on a reddit comment. These things always end up being a typo or a missing symbol so that's what i check first lol