From 63804c1999108d9e355c83d93baf5b59d8b010a8 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 00:44:03 -0500 Subject: [PATCH 01/10] more descriptive comments --- main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index ea1ab76a..b9b2861a 100644 --- a/main.lua +++ b/main.lua @@ -135,7 +135,7 @@ if not success then end --------------------------------------------------------------------------- --------------------------Handle Sacrifice Room----------------------------- +-------------Handle Sacrifice Room & Resetting Floor Trackers-------------- function EID:onNewFloor() EID.sacrificeCounter = {} if REPENTANCE then @@ -224,7 +224,7 @@ function EID:IsAltChoice(pickup) end --------------------------------------------------------------------------- ---------------------Handle Crane Game & Flip Item-------------------------- +-----------------Handle Crane Game & Flip Item Callbacks------------------- if REPENTANCE then EID.flipItemPositions = {} From 93fc928ea363385671f265c593416cee46d8983d Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 00:44:55 -0500 Subject: [PATCH 02/10] Checking unlock status does not work with TMTRAINER --- eid_api.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index 606b2c65..c5a2aa12 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -885,8 +885,9 @@ function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem) end function EID:isCollectibleUnlockedAnyPool(collectibleID) - --THIS FUNCTION IS FOR REPENTANCE ONLY due to using Repentance XML data; currently used by the Achievement Check, Spindown Dice, and Bag of Crafting - if not REPENTANCE then return true end + --THIS FUNCTION IS FOR REPENTANCE ONLY due to using Repentance XML data + --Currently used by the Achievement Check, Spindown Dice, and Bag of Crafting + if not REPENTANCE or EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) then return true end local item = EID.itemConfig:GetCollectible(collectibleID) if item == nil then return false end if EID.itemUnlockStates[collectibleID] == nil then From 5bc50eb903d2e41d2a6cbd6224e8907d40c1087e Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 01:39:53 -0500 Subject: [PATCH 03/10] Achievement-locked crafting results now use the Flip desc toggle --- eid_bagofcrafting.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/eid_bagofcrafting.lua b/eid_bagofcrafting.lua index 7b30cead..eef5d236 100644 --- a/eid_bagofcrafting.lua +++ b/eid_bagofcrafting.lua @@ -836,14 +836,21 @@ function EID:handleBagOfCraftingRendering() --Display the result of the 8 items in our bag if (showCraftingResult or EID.Config["BagOfCraftingDisplayMode"] == "Preview Only") and #EID.BagItems >= 8 then local craftingResult, backupResult = EID:calculateBagOfCrafting(EID.BagItems) + if Input.IsActionPressed(ButtonAction.ACTION_MAP, EID.player.ControllerIndex) then + local descriptionObj = EID:getDescriptionObj(5, 100, backupResult) + descriptionObj.Description = getHotkeyString() .. descriptionObj.Description + EID:printDescription(descriptionObj) + return true + end local descriptionObj = EID:getDescriptionObj(5, 100, craftingResult) + local infoText = EID:getDescriptionEntry("FlipItemToggleInfo") --prepend the Hide/Preview hotkeys to the description descriptionObj.Description = getHotkeyString() .. descriptionObj.Description - local backupObj = EID:getDescriptionObj(5, 100, backupResult) + local backupObjName = EID:getObjectName(5, 100, backupResult) if (backupResult ~= craftingResult) then local backupDesc = EID:getDescriptionEntry("CraftingPreviewBackup") EID:appendToDescription(descriptionObj,"#" .. backupDesc .. "#{{Collectible" .. backupResult .. "}} " .. - EID:getObjectName(5, 100, backupResult) .. "#" .. backupObj.Description) + backupObjName .. "#{{Blank}} " .. infoText) end EID:printDescription(descriptionObj) return true From e3224e63a530a4df186f2982a2c2c1ffcca7e259 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 03:43:06 -0500 Subject: [PATCH 04/10] glitched items are repentance only --- mod_config_menu.lua | 46 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/mod_config_menu.lua b/mod_config_menu.lua index b58d436a..d7b4e9d6 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -604,28 +604,30 @@ if MCMLoaded then end } ) - ------------Glitched Items-------------- - MCM.AddSetting( - "EID", - "Display", - { - Type = ModConfigMenu.OptionType.BOOLEAN, - CurrentSetting = function() - return EID.Config["DisplayGlitchedItemInfo"] - end, - Display = function() - local onOff = "False" - if EID.Config["DisplayGlitchedItemInfo"] then - onOff = "True" - end - return "Glitched Item Infos: " .. onOff - end, - OnChange = function(currentBool) - EID.Config["DisplayGlitchedItemInfo"] = currentBool - end, - Info = {"Note: The --luadebug launch option is required for more detailed glitched item descriptions"} - } - ) + if REPENTANCE then + ------------Glitched Items-------------- + MCM.AddSetting( + "EID", + "Display", + { + Type = ModConfigMenu.OptionType.BOOLEAN, + CurrentSetting = function() + return EID.Config["DisplayGlitchedItemInfo"] + end, + Display = function() + local onOff = "False" + if EID.Config["DisplayGlitchedItemInfo"] then + onOff = "True" + end + return "Glitched Item Infos: " .. onOff + end, + OnChange = function(currentBool) + EID.Config["DisplayGlitchedItemInfo"] = currentBool + end, + Info = {"Note: The --luadebug launch option is required for more detailed glitched item descriptions"} + } + ) + end --------Sacrifice Room--------- MCM.AddSetting( "EID", From 1c44ec67bd189b139f79f8c7a93030d5f8107343 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 03:46:40 -0500 Subject: [PATCH 05/10] Flip improvements with Tainted Isaac --- main.lua | 64 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/main.lua b/main.lua index b9b2861a..b39ca12f 100644 --- a/main.lua +++ b/main.lua @@ -226,19 +226,31 @@ end --------------------------------------------------------------------------- -----------------Handle Crane Game & Flip Item Callbacks------------------- +local initialItemNext = false +local flipItemNext = false if REPENTANCE then EID.flipItemPositions = {} local lastGetItemResult = {nil, nil, nil} -- itemID, Frame, gridIndex - + function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed) - -- Handle flip item + -- 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 + -- POST_NEW_ROOM then handles putting the result in the entity's GetData local curFrame = Isaac.GetFrameCount() - if not decrease and curFrame == lastGetItemResult[2] and lastGetItemResult[1] ~= nil then - local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() - EID.flipItemPositions[curRoomIndex][lastGetItemResult[3]] = selectedCollectible + if curFrame == lastGetItemResult[2] then + if initialItemNext then lastGetItemResult[1] = selectedCollectible + elseif flipItemNext then + local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() + if EID.flipItemPositions[curRoomIndex] == nil then + EID.flipItemPositions[curRoomIndex] = {} + end + EID.flipItemPositions[curRoomIndex][lastGetItemResult[3]] = selectedCollectible + end end - - -- Handle crane game + + -- 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 @@ -249,30 +261,30 @@ if REPENTANCE then end end - -- save last real collectible. for Flip Item handling - if decrease then - lastGetItemResult = {selectedCollectible, curFrame, nil} - end + initialItemNext = false + flipItemNext = false end EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible) -- Handle Flip Item spawn - function EID:postPickupInit(entity) - local curFrame = Isaac.GetFrameCount() - if entity.SubType == lastGetItemResult[1] and curFrame == lastGetItemResult[2] then - local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() - if EID.flipItemPositions[curRoomIndex] == nil then - EID.flipItemPositions[curRoomIndex] = {} - end - local gridPos = game:GetRoom():GetGridIndex(entity.Position) - local flipEntry = EID.flipItemPositions[curRoomIndex][gridPos] - if not flipEntry then - lastGetItemResult[3] = gridPos - else - entity:GetData()["EID_FlipItemID"] = flipEntry - end + 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) end @@ -438,6 +450,8 @@ if REPENTANCE then isMirrorRoom = game:GetLevel():GetCurrentRoom():IsMirrorWorld() -- Handle Flip Item + initialItemNext = false + flipItemNext = false local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() if EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_FLIP) and EID.flipItemPositions[curRoomIndex] then local pedestals = Isaac.FindByType(5, 100, -1, true, false) From 31a5c341467306a455d44792ff84ead2b46e27a4 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 19:21:47 -0500 Subject: [PATCH 06/10] 5.100.0 is now allowed; make it not crash --- eid_api.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eid_api.lua b/eid_api.lua index c5a2aa12..be499380 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -480,6 +480,7 @@ end function EID:getXMLDescription(Type, Variant, SubType) local tableName = EID:getTableName(Type, Variant, SubType) local desc= nil + if SubType == 0 then return "(no description available)" end if tableName == "collectibles" then desc = EID.itemConfig:GetCollectible(SubType).Description elseif tableName == "trinkets" then @@ -503,7 +504,7 @@ 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 + return isAllowed and (entity.SubType > 0 or EID:getEntityData(entity, "EID_FlipItemID")) 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 72eb2847423302f980033e516eb30fa6cc9f3ade Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 19:22:06 -0500 Subject: [PATCH 07/10] Add empty pedestal support --- eid_modifiers.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eid_modifiers.lua b/eid_modifiers.lua index 548bf009..0841bf9f 100644 --- a/eid_modifiers.lua +++ b/eid_modifiers.lua @@ -408,7 +408,8 @@ local game = Game() local function FlipCallback(descObj) local flipItemID = EID:getEntityData(descObj.Entity, "EID_FlipItemID") - if Input.IsActionPressed(ButtonAction.ACTION_MAP, EID.player.ControllerIndex) then + if flipItemID <= 0 then return descObj end + if descObj.ObjSubType == 0 or Input.IsActionPressed(ButtonAction.ACTION_MAP, EID.player.ControllerIndex) then local descEntry = EID:getDescriptionObj(5, 100, flipItemID) return descEntry end From d79b29178b523a9ffba0dc4143b0d65fc6469aff Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 19:22:43 -0500 Subject: [PATCH 08/10] WIP Flip improvements --- main.lua | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index b39ca12f..a19ed6cd 100644 --- a/main.lua +++ b/main.lua @@ -239,10 +239,10 @@ if REPENTANCE then -- POST_PICKUP_INIT occurs right before the Flip item is decided, so it sets us up to watch for the Flip item -- POST_NEW_ROOM then handles putting the result in the entity's GetData local curFrame = Isaac.GetFrameCount() + local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() if curFrame == lastGetItemResult[2] then if initialItemNext then lastGetItemResult[1] = selectedCollectible - elseif flipItemNext then - local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() + elseif flipItemNext and lastGetItemResult[1] then if EID.flipItemPositions[curRoomIndex] == nil then EID.flipItemPositions[curRoomIndex] = {} end @@ -250,6 +250,24 @@ if REPENTANCE then end end + -- Check if Flip item pedestals have moved (restock/Greed shops) + -- 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"] + print(gridPos) print(oldGridPos) + if EID.flipItemPositions[curRoomIndex][oldGridPos] and gridPos ~= oldGridPos then + print("chaing a position!") + EID.flipItemPositions[curRoomIndex][oldGridPos] = nil + EID.flipItemPositions[curRoomIndex][gridPos] = gridPos + pedestal:GetData()["EID_FlipItemPedestalGrid"] = gridPos + end + --index is unnecessary? + end + end + -- Handle Crane Game if itemPoolType == ItemPoolType.POOL_CRANE_GAME then for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do @@ -286,6 +304,24 @@ if REPENTANCE then if flipEntry then entity:GetData()["EID_FlipItemID"] = flipEntry end end EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.postPickupInit) + + 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) end --------------------------------------------------------------------------- @@ -460,6 +496,8 @@ if REPENTANCE then local flipEntry = EID.flipItemPositions[curRoomIndex][gridPos] if flipEntry then pedestal:GetData()["EID_FlipItemID"] = flipEntry + pedestal:GetData()["EID_FlipItemPedestalIndex"] = pedestal.Index + pedestal:GetData()["EID_FlipItemPedestalGrid"] = gridPos end end end From 5714fb1fd1b34b259edcd09ab1b9e29603fbaaf9 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 19:43:13 -0500 Subject: [PATCH 09/10] less post_pickup_init checks --- main.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/main.lua b/main.lua index a19ed6cd..2d72f623 100644 --- a/main.lua +++ b/main.lua @@ -257,14 +257,11 @@ if REPENTANCE then for _, pedestal in ipairs(pedestals) do local gridPos = game:GetRoom():GetGridIndex(pedestal.Position) local oldGridPos = pedestal:GetData()["EID_FlipItemPedestalGrid"] - print(gridPos) print(oldGridPos) if EID.flipItemPositions[curRoomIndex][oldGridPos] and gridPos ~= oldGridPos then - print("chaing a position!") EID.flipItemPositions[curRoomIndex][oldGridPos] = nil EID.flipItemPositions[curRoomIndex][gridPos] = gridPos pedestal:GetData()["EID_FlipItemPedestalGrid"] = gridPos end - --index is unnecessary? end end @@ -303,7 +300,7 @@ if REPENTANCE then 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) + EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.postPickupInit, PickupVariant.PICKUP_COLLECTIBLE) function EID:preUseFlip(_) local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() From c93cd80a4c04ee58710f3de0738d2bacfb0742bd Mon Sep 17 00:00:00 2001 From: Buurazu Date: Sat, 15 Jan 2022 19:49:33 -0500 Subject: [PATCH 10/10] futureproof the RegisterMod overwrite --- main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.lua b/main.lua index ef790919..ee3a4358 100644 --- a/main.lua +++ b/main.lua @@ -65,10 +65,10 @@ EID.ModIndicator = { } -- Useful to associate items to mods EID._currentMod = "" local OldRegisterMod = RegisterMod -RegisterMod = function (modName, apiVersion) +RegisterMod = function (modName, apiVersion, ...) EID._currentMod = modName EID.ModIndicator[modName] = { Name = modName, Icon = nil } - return OldRegisterMod(modName, apiVersion) + return OldRegisterMod(modName, apiVersion, ...) end ------- Load all modules and other stuff ------ @@ -1176,4 +1176,4 @@ end if EID.enableDebug then require("eid_debugging") -end \ No newline at end of file +end