From 830d7b7fd64c3943db9eecf85b70a216b91c0b7a Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Sat, 25 Jan 2025 00:12:40 +0100 Subject: [PATCH] small code improvements --- features/eid_api.lua | 9 +++++---- features/eid_modifiers.lua | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/features/eid_api.lua b/features/eid_api.lua index 03e20103..1c7f067e 100644 --- a/features/eid_api.lua +++ b/features/eid_api.lua @@ -2931,15 +2931,16 @@ function EID:WatchForGlitchedCrown() local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() EID.GlitchedCrownCheck[curRoomIndex] = EID.GlitchedCrownCheck[curRoomIndex] or {} - + for _, entity in ipairs(Isaac.FindByType(5, 100, -1, true, false)) do + local index = entity.InitSeed..entity.Index -- Use InitSeed and Index to prevent any Diplopia weirdness - EID.GlitchedCrownCheck[curRoomIndex][entity.InitSeed..entity.Index] = EID.GlitchedCrownCheck[curRoomIndex][entity.InitSeed..entity.Index] or {} + EID.GlitchedCrownCheck[curRoomIndex][index] = EID.GlitchedCrownCheck[curRoomIndex][index] or {} -- Initialize the data about this pedestal showing its current item ID, if necessary -- in order to sort the items displayed, while also trashing items that haven't shown up in a while, keep both "initial frame seen" and "last frame seen" - EID.GlitchedCrownCheck[curRoomIndex][entity.InitSeed..entity.Index][entity.SubType] = EID.GlitchedCrownCheck[curRoomIndex][entity.InitSeed..entity.Index][entity.SubType] or {EID.GameUpdateCount, EID.GameUpdateCount} + EID.GlitchedCrownCheck[curRoomIndex][index][entity.SubType] = EID.GlitchedCrownCheck[curRoomIndex][index][entity.SubType] or {EID.GameUpdateCount, EID.GameUpdateCount} -- update the last frame seen for the pedestal's current collectible ID - EID.GlitchedCrownCheck[curRoomIndex][entity.InitSeed..entity.Index][entity.SubType][2] = EID.GameUpdateCount + EID.GlitchedCrownCheck[curRoomIndex][index][entity.SubType][2] = EID.GameUpdateCount end end end diff --git a/features/eid_modifiers.lua b/features/eid_modifiers.lua index 69de00df..35ff5791 100644 --- a/features/eid_modifiers.lua +++ b/features/eid_modifiers.lua @@ -919,11 +919,12 @@ if EID.isRepentance then if not descObj.Entity or inGlitchedCrown then return descObj end local entity = descObj.Entity local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() + local pedestalID = descObj.Entity.InitSeed .. descObj.Entity.Index - if EID.GlitchedCrownCheck[curRoomIndex] and EID.GlitchedCrownCheck[curRoomIndex][descObj.Entity.InitSeed .. descObj.Entity.Index] then + if EID.GlitchedCrownCheck[curRoomIndex] and EID.GlitchedCrownCheck[curRoomIndex][pedestalID] then -- this table has collectible ID keys that define the first frame and most recent frame that that ID has been seen on this pedestal -- we need to filter out items that haven't been seen in a while (due to a reroll perhaps), then sort by first frame - local pedestalID = descObj.Entity.InitSeed .. descObj.Entity.Index + local items = EID.GlitchedCrownCheck[curRoomIndex][pedestalID] local sortedItems = {} for id, frames in pairs(items) do