diff --git a/eid_api.lua b/eid_api.lua index 8233db95..749893f6 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -484,6 +484,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 @@ -507,7 +508,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)] @@ -905,8 +906,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 diff --git a/eid_bagofcrafting.lua b/eid_bagofcrafting.lua index 83d32541..35aa2386 100644 --- a/eid_bagofcrafting.lua +++ b/eid_bagofcrafting.lua @@ -834,14 +834,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 diff --git a/eid_modifiers.lua b/eid_modifiers.lua index cce49a19..fd5b5236 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 diff --git a/main.lua b/main.lua index a3b7f050..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 ------ @@ -149,7 +149,7 @@ if not success then end --------------------------------------------------------------------------- --------------------------Handle Sacrifice Room----------------------------- +-------------Handle Sacrifice Room & Resetting Floor Trackers-------------- function EID:onNewFloor() EID.sacrificeCounter = {} if REPENTANCE then @@ -238,21 +238,48 @@ function EID:IsAltChoice(pickup) end --------------------------------------------------------------------------- ---------------------Handle Crane Game & Flip Item-------------------------- +-----------------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 + local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() + if curFrame == lastGetItemResult[2] then + if initialItemNext then lastGetItemResult[1] = selectedCollectible + elseif flipItemNext and lastGetItemResult[1] then + if EID.flipItemPositions[curRoomIndex] == nil then + EID.flipItemPositions[curRoomIndex] = {} + end + EID.flipItemPositions[curRoomIndex][lastGetItemResult[3]] = selectedCollectible + end end - - -- Handle crane game + + -- 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"] + 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 + + -- 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 @@ -263,31 +290,49 @@ 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: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) - 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 + 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_POST_PICKUP_INIT, EID.postPickupInit) + EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.preUseFlip, CollectibleType.COLLECTIBLE_FLIP) end --------------------------------------------------------------------------- @@ -463,6 +508,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) @@ -471,6 +518,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 @@ -1127,4 +1176,4 @@ end if EID.enableDebug then require("eid_debugging") -end \ No newline at end of file +end diff --git a/mod_config_menu.lua b/mod_config_menu.lua index c6014beb..26204ef4 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -648,28 +648,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",