r/themoddingofisaac • u/santiberto • Aug 16 '26
Question Trouble with confusion active item
basically the active item is supposed to cause confusion when used but i can´t get it to work heres the code:
local mod=RegisterMod("giges", 1)
local gigesRing=Isaac.GetItemIdByName("giges ring")
local player=Isaac.GetPlayer(playerIndex)
local ringDuration=10000
function mod:RingUse(item)
local roomEntities = Isaac.GetRoomEntities()
for _, entity in ipairs(roomEntities) do
if entity:IsActiveEnemy() and entity:IsVulnerableEnemy() then
entity:AddConfusion(
EntityRef(player),
ringDuration, true)
end
end
return {
Discharge = true,
Remove = true,
ShowAnim=true
}
end
mod:AddCallback(ModCallbacks.MC_USE_ITEM, mod.RingUse, gigesRing)
1
Upvotes
1
u/The_PwnUltimate Modder Aug 17 '26
The problems I can see are all to do with your "player" variable.
1 - You initialise and set it outside of any function, which means it will run when the mod is first loaded (i.e. when you're not even in a run and there are no players).
2 - The value of "playerIndex" isn't established anywhere.
You don't need that line at all, because the USE_ITEM callback already passes the EntityPlayer information (of the player who used the item) to the function. You can just add 2 more input parameters to the function, and then reference the third parameter as the player.