From 962c7f0ced0ec407c4e0661ce647e3e041f07d5f Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 20:14:54 -0500 Subject: [PATCH 1/6] Change print to Isaac.DebugString --- eid_tmtrainer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eid_tmtrainer.lua b/eid_tmtrainer.lua index 09dc58ab..eb81f2e1 100644 --- a/eid_tmtrainer.lua +++ b/eid_tmtrainer.lua @@ -28,7 +28,7 @@ local function entityToName(e, plural) local name = localizedNames[e] or EID.XMLEntityNames[e] or localizedNames[eWithZero] or EID.XMLEntityNames[eWithZero] or e --print out entities with no name yet - if name == e then print("No name found for " .. e .. " (could be modded)") + if name == e then Isaac.DebugString("No name found for " .. e .. " (could be modded)") elseif plural then name = name .. localizedNames["pluralize"] end return name From 04364ff19ad74145c19a971ae2c5789b0ae45799 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sun, 16 Jan 2022 03:52:44 -0500 Subject: [PATCH 2/6] saving what i have --- main.lua | 156 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 59 deletions(-) diff --git a/main.lua b/main.lua index ee3a4358..e63594ea 100644 --- a/main.lua +++ b/main.lua @@ -244,13 +244,27 @@ local initialItemNext = false local flipItemNext = false if REPENTANCE then EID.flipItemPositions = {} - local lastGetItemResult = {nil, nil, nil} -- itemID, Frame, gridIndex + EID.flipItemSeeds = {} - function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed) + local lastGetItemResult = {nil, nil, nil, nil} -- itemID, Frame, gridIndex, InitSeed + + function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, _) + -- Handle Crane Game + if itemPoolType == ItemPoolType.POOL_CRANE_GAME then + for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do + if not crane:GetSprite():IsPlaying("Broken") then + if not EID.CraneItemType[tostring(crane.InitSeed)] then + EID.CraneItemType[tostring(crane.InitSeed)] = selectedCollectible + end + end + end + end + -- Handle Flip item -- PRE_ROOM_ENTITY_SPAWN sets us up to watch for the first POST_GET_COLLECTIBLE for this pedestal -- (Tainted Isaac and Glitched Crown cause additional calls that have to be ignored) -- POST_PICKUP_INIT occurs right before the Flip item is decided, so it sets us up to watch for the Flip item + -- (it also watches for item rerolls to fill the new entity's GetData) -- POST_NEW_ROOM then handles putting the result in the entity's GetData local curFrame = Isaac.GetFrameCount() local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() @@ -260,12 +274,35 @@ if REPENTANCE then if EID.flipItemPositions[curRoomIndex] == nil then EID.flipItemPositions[curRoomIndex] = {} end - EID.flipItemPositions[curRoomIndex][lastGetItemResult[3]] = selectedCollectible + EID.flipItemPositions[curRoomIndex][lastGetItemResult[4]] = {selectedCollectible, lastGetItemResult[3]} end end - -- Check if Flip item pedestals have moved (restock/Greed shops) + initialItemNext = false + flipItemNext = false + end + EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible) + + -- Handle Flip Item spawn + function EID:preRoomEntitySpawn(entityType, variant, subtype, gridIndex, _) + flipItemNext = false + if entityType == 5 and (variant == 100 or variant == 150) then + lastGetItemResult = {nil, Isaac.GetFrameCount(), gridIndex, nil} + initialItemNext = true + end + end + EID:AddCallback(ModCallbacks.MC_PRE_ROOM_ENTITY_SPAWN, EID.preRoomEntitySpawn) + + function EID:postPickupInit(entity) + flipItemNext = true + lastGetItemResult[4] = entity.InitSeed + + local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() + local gridPos = game:GetRoom():GetGridIndex(entity.Position) + + -- Check if Flip item pedestals have moved (restock/Greed shops, Damocles) -- BUG if you leave the room before the new shop item spawns?? + --[[ if EID.flipItemPositions[curRoomIndex] then local pedestals = Isaac.FindByType(5, 100, -1, true, false) for _, pedestal in ipairs(pedestals) do @@ -278,61 +315,63 @@ if REPENTANCE then end end end - - -- Handle Crane Game - if itemPoolType == ItemPoolType.POOL_CRANE_GAME then - for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do - if not crane:GetSprite():IsPlaying("Broken") then - if not EID.CraneItemType[tostring(crane.InitSeed)] then - EID.CraneItemType[tostring(crane.InitSeed)] = selectedCollectible + ]] + print(entity:ToPickup().ShopItemId) + -- Update a Flip item's init seed after D6 rerolls or using Flip (aka Grid Index didn't change, Init Seed did) + if EID.flipItemPositions[curRoomIndex] and not EID.flipItemPositions[curRoomIndex][entity.InitSeed] then + -- Check pedestal grid indexes (fixes bugs with restock shops) + EID:CheckFlipGridIndexes() + for k,v in pairs(EID.flipItemPositions[curRoomIndex]) do + + --[[if v[3] == entity.Index then + print("index match!") + EID.flipItemPositions[curRoomIndex][entity.InitSeed] = v + EID.flipItemPositions[curRoomIndex][k] = nil + end]] + if v[2] == gridPos then + print(k) + print(EID.flipItemPositions[curRoomIndex][k][1]) + EID.flipItemPositions[curRoomIndex][entity.InitSeed] = v + EID.flipItemPositions[curRoomIndex][k] = nil + + --k = entity.InitSeed --does this work lol + print(entity.InitSeed) + print(EID.flipItemPositions[curRoomIndex][entity.InitSeed][1]) + break + end + end + end + -- Give this new entity its Flip Item data if possible + local flipEntry = EID.flipItemPositions[curRoomIndex] and EID.flipItemPositions[curRoomIndex][entity.InitSeed] + if flipEntry then + entity:GetData()["EID_FlipItemID"] = flipEntry[1] + end + end + EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.postPickupInit, PickupVariant.PICKUP_COLLECTIBLE) + + -- Before using D6, double-check all flippable pedestal's grid index, since their init seed will change + -- (Note that items like D100, Cracked Dice, and Dice Shard all trigger a D6 PRE_USE_ITEM) + -- Before using Flip, swap all flippable pedestal's current item with the flip one (also, fix grid index if needed) + function EID:CheckFlipGridIndexes(collectibleType) + if collectibleType == CollectibleType.COLLECTIBLE_FLIP or collectibleType == CollectibleType.COLLECTIBLE_D6 or collectibleType == CollectibleType.COLLECTIBLE_ETERNAL_D6 or collectibleType == true then + local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() + if EID.flipItemPositions[curRoomIndex] then + local pedestals = Isaac.FindByType(5, 100, -1, true, false) + for _, pedestal in ipairs(pedestals) do + if EID.flipItemPositions[curRoomIndex][pedestal.InitSeed] then + local gridPos = game:GetRoom():GetGridIndex(pedestal.Position) + EID.flipItemPositions[curRoomIndex][pedestal.InitSeed][2] = gridPos + if collectibleType == CollectibleType.COLLECTIBLE_FLIP then + -- don't swap a flip shadow with an empty pedestal! + if pedestal.SubType == 0 then EID.flipItemPositions[curRoomIndex][pedestal.InitSeed] = nil + else EID.flipItemPositions[curRoomIndex][pedestal.InitSeed][1] = pedestal.SubType end + end end end end end - - initialItemNext = false - flipItemNext = false end - EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible) - - -- Handle Flip Item spawn - function EID:preRoomEntitySpawn(entityType, variant, subtype, gridIndex, seed) - flipItemNext = false - if entityType == 5 and (variant == 100 or variant == 150) then - lastGetItemResult = {nil, Isaac.GetFrameCount(), gridIndex} - initialItemNext = true - end - end - EID:AddCallback(ModCallbacks.MC_PRE_ROOM_ENTITY_SPAWN, EID.preRoomEntitySpawn) - - function EID:postPickupInit(entity) - flipItemNext = true - - -- Keep the Flip item the same for pedestal rerolls - local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() - local gridPos = game:GetRoom():GetGridIndex(entity.Position) - local flipEntry = EID.flipItemPositions[curRoomIndex] and EID.flipItemPositions[curRoomIndex][gridPos] - if flipEntry then entity:GetData()["EID_FlipItemID"] = flipEntry end - end - EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.postPickupInit, PickupVariant.PICKUP_COLLECTIBLE) - - function EID:preUseFlip(_) - local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() - if EID.flipItemPositions[curRoomIndex] then - local pedestals = Isaac.FindByType(5, 100, -1, true, false) - for _, pedestal in ipairs(pedestals) do - local gridPos = game:GetRoom():GetGridIndex(pedestal.Position) - if EID.flipItemPositions[curRoomIndex][gridPos] then - -- don't swap a flip shadow with an empty pedestal! - if pedestal.SubType == 0 then EID.flipItemPositions[curRoomIndex][gridPos] = nil - else EID.flipItemPositions[curRoomIndex][gridPos] = pedestal.SubType end - --postPickupInit will take care of assigning it to the entity's data - end - - end - end - end - EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.preUseFlip, CollectibleType.COLLECTIBLE_FLIP) + EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.CheckFlipGridIndexes) end --------------------------------------------------------------------------- @@ -505,6 +544,7 @@ end local isMirrorRoom = false if REPENTANCE then function EID:onNewRoom() + print("in post_new_room") isMirrorRoom = game:GetLevel():GetCurrentRoom():IsMirrorWorld() -- Handle Flip Item @@ -514,12 +554,10 @@ if REPENTANCE then if EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_FLIP) and EID.flipItemPositions[curRoomIndex] then local pedestals = Isaac.FindByType(5, 100, -1, true, false) for _, pedestal in ipairs(pedestals) do - local gridPos = game:GetRoom():GetGridIndex(pedestal.Position) - local flipEntry = EID.flipItemPositions[curRoomIndex][gridPos] + local flipEntry = EID.flipItemPositions[curRoomIndex][pedestal.InitSeed] if flipEntry then - pedestal:GetData()["EID_FlipItemID"] = flipEntry - pedestal:GetData()["EID_FlipItemPedestalIndex"] = pedestal.Index - pedestal:GetData()["EID_FlipItemPedestalGrid"] = gridPos + pedestal:GetData()["EID_FlipItemID"] = flipEntry[1] + flipEntry[2] = game:GetRoom():GetGridIndex(pedestal.Position) end end end From 708e4969a1943f52b611f4070eb7d0c90c2e4761 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sun, 16 Jan 2022 04:11:59 -0500 Subject: [PATCH 3/6] fix bug with empty Flippable pedestals after you dropped Flip --- eid_api.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eid_api.lua b/eid_api.lua index 749893f6..9c0ea8dd 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -508,7 +508,9 @@ function EID:hasDescription(entity) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_TRINKET and EID.Config["DisplayTrinketInfo"]) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_TAROTCARD and EID.Config["DisplayCardInfo"]) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_PILL and EID.Config["DisplayPillInfo"]) - return isAllowed and (entity.SubType > 0 or EID:getEntityData(entity, "EID_FlipItemID")) + return isAllowed and (entity.SubType > 0 or + -- For Flip descriptions, allow 5.100.0 pedestals to have descriptions under VERY specific criteria! + (REPENTANCE and EID:getEntityData(entity, "EID_FlipItemID") and EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_FLIP))) end if entity.Type == 6 and entity.Variant == 16 and EID.Config["DisplayCraneInfo"] and REPENTANCE then isAllowed = not entity:GetSprite():IsPlaying("Broken") and not entity:GetSprite():IsPlaying("Prize") and EID.CraneItemType[tostring(entity.InitSeed)] From 0e8a8a06273cd6f2814bdd5897a9a080a089a23a Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sun, 16 Jan 2022 04:21:46 -0500 Subject: [PATCH 4/6] More Flip improvements --- main.lua | 60 ++++++++++++-------------------------------------------- 1 file changed, 13 insertions(+), 47 deletions(-) diff --git a/main.lua b/main.lua index e63594ea..a5ef4829 100644 --- a/main.lua +++ b/main.lua @@ -300,43 +300,14 @@ if REPENTANCE then local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() local gridPos = game:GetRoom():GetGridIndex(entity.Position) - -- Check if Flip item pedestals have moved (restock/Greed shops, Damocles) - -- BUG if you leave the room before the new shop item spawns?? - --[[ - if EID.flipItemPositions[curRoomIndex] then - local pedestals = Isaac.FindByType(5, 100, -1, true, false) - for _, pedestal in ipairs(pedestals) do - local gridPos = game:GetRoom():GetGridIndex(pedestal.Position) - local oldGridPos = pedestal:GetData()["EID_FlipItemPedestalGrid"] - if EID.flipItemPositions[curRoomIndex][oldGridPos] and gridPos ~= oldGridPos then - EID.flipItemPositions[curRoomIndex][oldGridPos] = nil - EID.flipItemPositions[curRoomIndex][gridPos] = gridPos - pedestal:GetData()["EID_FlipItemPedestalGrid"] = gridPos - end - end - end - ]] - print(entity:ToPickup().ShopItemId) -- Update a Flip item's init seed after D6 rerolls or using Flip (aka Grid Index didn't change, Init Seed did) if EID.flipItemPositions[curRoomIndex] and not EID.flipItemPositions[curRoomIndex][entity.InitSeed] then - -- Check pedestal grid indexes (fixes bugs with restock shops) + -- Fix pedestal grid indexes (fixes bugs with restock shops, hopefully it isn't laggy) EID:CheckFlipGridIndexes() for k,v in pairs(EID.flipItemPositions[curRoomIndex]) do - - --[[if v[3] == entity.Index then - print("index match!") - EID.flipItemPositions[curRoomIndex][entity.InitSeed] = v - EID.flipItemPositions[curRoomIndex][k] = nil - end]] if v[2] == gridPos then - print(k) - print(EID.flipItemPositions[curRoomIndex][k][1]) EID.flipItemPositions[curRoomIndex][entity.InitSeed] = v EID.flipItemPositions[curRoomIndex][k] = nil - - --k = entity.InitSeed --does this work lol - print(entity.InitSeed) - print(EID.flipItemPositions[curRoomIndex][entity.InitSeed][1]) break end end @@ -349,23 +320,20 @@ if REPENTANCE then end EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.postPickupInit, PickupVariant.PICKUP_COLLECTIBLE) - -- Before using D6, double-check all flippable pedestal's grid index, since their init seed will change - -- (Note that items like D100, Cracked Dice, and Dice Shard all trigger a D6 PRE_USE_ITEM) -- Before using Flip, swap all flippable pedestal's current item with the flip one (also, fix grid index if needed) function EID:CheckFlipGridIndexes(collectibleType) - if collectibleType == CollectibleType.COLLECTIBLE_FLIP or collectibleType == CollectibleType.COLLECTIBLE_D6 or collectibleType == CollectibleType.COLLECTIBLE_ETERNAL_D6 or collectibleType == true then - local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() - if EID.flipItemPositions[curRoomIndex] then - local pedestals = Isaac.FindByType(5, 100, -1, true, false) - for _, pedestal in ipairs(pedestals) do - if EID.flipItemPositions[curRoomIndex][pedestal.InitSeed] then - local gridPos = game:GetRoom():GetGridIndex(pedestal.Position) - EID.flipItemPositions[curRoomIndex][pedestal.InitSeed][2] = gridPos - if collectibleType == CollectibleType.COLLECTIBLE_FLIP then - -- don't swap a flip shadow with an empty pedestal! - if pedestal.SubType == 0 then EID.flipItemPositions[curRoomIndex][pedestal.InitSeed] = nil - else EID.flipItemPositions[curRoomIndex][pedestal.InitSeed][1] = pedestal.SubType end - end + local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() + if EID.flipItemPositions[curRoomIndex] then + local pedestals = Isaac.FindByType(5, 100, -1, true, false) + for _, pedestal in ipairs(pedestals) do + local flipEntry = EID.flipItemPositions[curRoomIndex][pedestal.InitSeed] + if flipEntry then + local gridPos = game:GetRoom():GetGridIndex(pedestal.Position) + flipEntry[2] = gridPos + if collectibleType == CollectibleType.COLLECTIBLE_FLIP then + -- don't swap a flip shadow with an empty pedestal! + if pedestal.SubType == 0 then flipEntry = nil + else flipEntry[1] = pedestal.SubType end end end end @@ -544,7 +512,6 @@ end local isMirrorRoom = false if REPENTANCE then function EID:onNewRoom() - print("in post_new_room") isMirrorRoom = game:GetLevel():GetCurrentRoom():IsMirrorWorld() -- Handle Flip Item @@ -557,7 +524,6 @@ if REPENTANCE then local flipEntry = EID.flipItemPositions[curRoomIndex][pedestal.InitSeed] if flipEntry then pedestal:GetData()["EID_FlipItemID"] = flipEntry[1] - flipEntry[2] = game:GetRoom():GetGridIndex(pedestal.Position) end end end From 22803813545daa7ece17aac063fb8b21ee41574b Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sun, 16 Jan 2022 04:23:33 -0500 Subject: [PATCH 5/6] More Flip improvements --- main.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/main.lua b/main.lua index a5ef4829..2665b6ee 100644 --- a/main.lua +++ b/main.lua @@ -244,7 +244,6 @@ local initialItemNext = false local flipItemNext = false if REPENTANCE then EID.flipItemPositions = {} - EID.flipItemSeeds = {} local lastGetItemResult = {nil, nil, nil, nil} -- itemID, Frame, gridIndex, InitSeed From b3bc547cf46d68113c114f88a41aad9d0d563d9d Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sun, 16 Jan 2022 04:25:38 -0500 Subject: [PATCH 6/6] re-add the Collectible_Flip restriction --- main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.lua b/main.lua index 2665b6ee..c7f4ec81 100644 --- a/main.lua +++ b/main.lua @@ -247,7 +247,7 @@ if REPENTANCE then local lastGetItemResult = {nil, nil, nil, nil} -- itemID, Frame, gridIndex, InitSeed - function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, _) + function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed) -- Handle Crane Game if itemPoolType == ItemPoolType.POOL_CRANE_GAME then for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do @@ -283,7 +283,7 @@ if REPENTANCE then EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible) -- Handle Flip Item spawn - function EID:preRoomEntitySpawn(entityType, variant, subtype, gridIndex, _) + function EID:preRoomEntitySpawn(entityType, variant, subtype, gridIndex, seed) flipItemNext = false if entityType == 5 and (variant == 100 or variant == 150) then lastGetItemResult = {nil, Isaac.GetFrameCount(), gridIndex, nil} @@ -338,7 +338,7 @@ if REPENTANCE then end end end - EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.CheckFlipGridIndexes) + EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.CheckFlipGridIndexes, CollectibleType.COLLECTIBLE_FLIP) end ---------------------------------------------------------------------------