From 25aea6f7d889b69563f8996576de969d855b2cf2 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Wed, 15 Dec 2021 15:41:49 -0600 Subject: [PATCH 1/5] Crane Game support --- eid_api.lua | 2 +- main.lua | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index 87926dc2..d7612ec5 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -491,7 +491,7 @@ function EID:hasDescription(entity) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_PILL and EID.Config["DisplayPillInfo"]) return isAllowed and entity.SubType > 0 end - isAllowed = isAllowed or (entity.Type == 1000 and entity.Variant == EffectVariant.DICE_FLOOR and EID.Config["DisplayDiceInfo"]) + isAllowed = isAllowed or (entity.Type == 1000 and entity.Variant == EffectVariant.DICE_FLOOR and EID.Config["DisplayDiceInfo"]) or (entity.Type == 6 and entity.Variant == 16) return isAllowed end diff --git a/main.lua b/main.lua index e5ad0a69..804162fe 100644 --- a/main.lua +++ b/main.lua @@ -213,6 +213,21 @@ function EID:IsAltChoice(pickup) return true end +--------------------------------------------------------------------------- +-------------------------Handle Crane Game----------------------------- + +function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed) + if itemPoolType == ItemPoolType.POOL_CRANE_GAME then + local cranes = Isaac.FindByType(6, 16) + for _, crane in pairs(cranes) do + if not EID:getEntityData(crane, "EID_CraneItemType") then + crane:GetData()["EID_CraneItemType"] = selectedCollectible + end + end + end +end +EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible) + --------------------------------------------------------------------------- ---------------------------Printing Functions------------------------------ @@ -755,12 +770,27 @@ local function onRender(t) EID:printDescription(origDesc) return end - + if closest.Type == 1000 and closest.Variant == 76 then EID:printDescription(EID:getDescriptionObj(closest.Type, closest.Variant, closest.SubType+1)) return end + if closest.Type == 6 and closest.Variant == 16 then + --Handle Crane Game + if EID:getEntityData(closest, "EID_CraneItemType") then + if EID:getEntityData(closest, "EID_DontHide") ~= true then + if (EID:hasCurseBlind() and EID.Config["DisableOnCurse"]) or (game.Challenge == Challenge.CHALLENGE_APRILS_FOOL and EID.Config["DisableOnAprilFoolsChallenge"]) then + EID:renderQuestionMark() + return + end + end + local descriptionObj = EID:getDescriptionObj(5, 100, EID:getEntityData(closest, "EID_CraneItemType")) + + EID:printDescription(descriptionObj) + end + end + if closest.Variant == PickupVariant.PICKUP_TRINKET then --Handle Trinkets local trinketID = closest.SubType From 9c84886155a87d07867bcebe8ce4f9fe9d354114 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Wed, 15 Dec 2021 16:10:09 -0600 Subject: [PATCH 2/5] Update main.lua --- main.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/main.lua b/main.lua index 804162fe..857946d4 100644 --- a/main.lua +++ b/main.lua @@ -788,6 +788,7 @@ local function onRender(t) local descriptionObj = EID:getDescriptionObj(5, 100, EID:getEntityData(closest, "EID_CraneItemType")) EID:printDescription(descriptionObj) + return end end From 88b3ea26f1641310099ce87d9d67e7350bdc2e88 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Wed, 15 Dec 2021 17:23:04 -0600 Subject: [PATCH 3/5] Save data and other tweaks --- eid_api.lua | 2 +- main.lua | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index d7612ec5..c7f704da 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -491,7 +491,7 @@ function EID:hasDescription(entity) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_PILL and EID.Config["DisplayPillInfo"]) return isAllowed and entity.SubType > 0 end - isAllowed = isAllowed or (entity.Type == 1000 and entity.Variant == EffectVariant.DICE_FLOOR and EID.Config["DisplayDiceInfo"]) or (entity.Type == 6 and entity.Variant == 16) + isAllowed = isAllowed or (entity.Type == 1000 and entity.Variant == EffectVariant.DICE_FLOOR and EID.Config["DisplayDiceInfo"]) or (entity.Type == 6 and entity.Variant == 16 and (not entity:GetSprite():IsPlaying("Broken") and not entity:GetSprite():IsPlaying("Prize"))) return isAllowed end diff --git a/main.lua b/main.lua index 857946d4..315cec68 100644 --- a/main.lua +++ b/main.lua @@ -28,6 +28,7 @@ EID.sacrificeCounter = {} EID.itemConfig = Isaac.GetItemConfig() EID.effectList = {["76"] = true} EID.itemUnlockStates = {} +EID.CraneItemType = {} -- Sprite inits EID.IconSprite = Sprite() @@ -218,10 +219,11 @@ end function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed) if itemPoolType == ItemPoolType.POOL_CRANE_GAME then - local cranes = Isaac.FindByType(6, 16) - for _, crane in pairs(cranes) do - if not EID:getEntityData(crane, "EID_CraneItemType") then - crane:GetData()["EID_CraneItemType"] = selectedCollectible + 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 @@ -557,6 +559,7 @@ EID.hasValidWalkingpath = true function EID:onGameUpdate() EID:setPlayer() + --Fix Overlapping Pedestals local curPositions = {} for _, entity in ipairs(Isaac.FindByType(5, 100, -1, true, false)) do @@ -571,6 +574,14 @@ function EID:onGameUpdate() table.insert(curPositions, {entity, entity.Position}) end + for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do + if EID.CraneItemType[tostring(crane.InitSeed)] then + if crane:GetSprite():IsPlaying("Prize") then + EID.CraneItemType[tostring(crane.InitSeed)] = nil + end + end + end + if not EID.Config["DisplayObstructedCardInfo"] or not EID.Config["DisplayObstructedPillInfo"] or not EID.Config["DisplayObstructedSoulstoneInfo"] then if EID.lastDescriptionEntity == nil or (EID.Config["DisableObstructionOnFlight"] and EID.player.CanFly) then if EID.pathCheckerEntity ~= nil then @@ -778,14 +789,16 @@ local function onRender(t) if closest.Type == 6 and closest.Variant == 16 then --Handle Crane Game - if EID:getEntityData(closest, "EID_CraneItemType") then + + if EID.CraneItemType[tostring(closest.InitSeed)] then if EID:getEntityData(closest, "EID_DontHide") ~= true then if (EID:hasCurseBlind() and EID.Config["DisableOnCurse"]) or (game.Challenge == Challenge.CHALLENGE_APRILS_FOOL and EID.Config["DisableOnAprilFoolsChallenge"]) then EID:renderQuestionMark() return end end - local descriptionObj = EID:getDescriptionObj(5, 100, EID:getEntityData(closest, "EID_CraneItemType")) + local collectibleID = EID.CraneItemType[tostring(closest.InitSeed)] + local descriptionObj = EID:getDescriptionObj(5, 100, collectibleID) EID:printDescription(descriptionObj) return @@ -882,8 +895,10 @@ if EID.MCMLoaded or REPENTANCE then if REPENTANCE and isSave then EID.BagItems = savedEIDConfig["BagContent"] EID.bagOfCraftingRoomQueries = savedEIDConfig["BagFloorContent"] + EID.CraneItemType = savedEIDConfig["CraneItemType"] savedEIDConfig["BagContent"] = nil savedEIDConfig["BagFloorContent"] = nil + savedEIDConfig["CraneItemType"] = nil else EID.BagItems = {} end @@ -927,6 +942,7 @@ if EID.MCMLoaded or REPENTANCE then if REPENTANCE then EID.Config["BagContent"] = EID.BagItems or {} EID.Config["BagFloorContent"] = EID.bagOfCraftingRoomQueries or {} + EID.Config["CraneItemType"] = EID.CraneItemType or {} end EID.SaveData(EID, json.encode(EID.Config)) EID:hidePermanentText() From 52cbc5781f4019f2e5ee484f657ad00552b40fcb Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Wed, 15 Dec 2021 17:30:51 -0600 Subject: [PATCH 4/5] Update main.lua --- main.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/main.lua b/main.lua index 315cec68..49d97653 100644 --- a/main.lua +++ b/main.lua @@ -138,6 +138,7 @@ function EID:onNewFloor() if REPENTANCE then EID.bagOfCraftingRoomQueries = {} EID.bagOfCraftingFloorQuery = {} + EID.CraneItemType = {} end end EID:AddCallback(ModCallbacks.MC_POST_NEW_LEVEL, EID.onNewFloor) From fd71cb2643a238bad3863fb771489ad025970833 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Wed, 15 Dec 2021 17:47:59 -0600 Subject: [PATCH 5/5] Config stuff --- eid_api.lua | 5 ++++- eid_config.lua | 8 ++++++++ mod_config_menu.lua | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/eid_api.lua b/eid_api.lua index c7f704da..4a0b5c5c 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -491,7 +491,10 @@ function EID:hasDescription(entity) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_PILL and EID.Config["DisplayPillInfo"]) return isAllowed and entity.SubType > 0 end - isAllowed = isAllowed or (entity.Type == 1000 and entity.Variant == EffectVariant.DICE_FLOOR and EID.Config["DisplayDiceInfo"]) or (entity.Type == 6 and entity.Variant == 16 and (not entity:GetSprite():IsPlaying("Broken") and not entity:GetSprite():IsPlaying("Prize"))) + 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") + end + isAllowed = isAllowed or (entity.Type == 1000 and entity.Variant == EffectVariant.DICE_FLOOR and EID.Config["DisplayDiceInfo"]) return isAllowed end diff --git a/eid_config.lua b/eid_config.lua index 280cd321..4ccc7b68 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -195,6 +195,13 @@ EID.UserConfig = { -- Default = true ["DisplayDiceInfo"] = true, + --------Crane Game--------- + -- REPENTANCE ONLY!!! + + -- Toggle Display for items inside of a Crane Game + -- Default = true + ["DisplayCraneInfo"] = true, + ---------Bag of Crafting----------- -- REPENTANCE ONLY!!! @@ -355,6 +362,7 @@ EID.DefaultConfig = { ["DisplaySacrificeInfo"] = true, ["DisplayDiceInfo"] = true, ["DisplayBagOfCrafting"] = "always", + ["DisplayCraneInfo"] = true, ["BagOfCraftingResults"] = 7, ["BagOfCraftingCombinationMax"] = 12, ["BagOfCraftingRandomResults"] = 400, diff --git a/mod_config_menu.lua b/mod_config_menu.lua index a1f6c421..7c3c619c 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -619,9 +619,33 @@ if MCMLoaded then } ) + + local diceSteps = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} if REPENTANCE then + --------Crane Game--------- + MCM.AddSetting( + "EID", + "Display", + { + Type = ModConfigMenu.OptionType.BOOLEAN, + CurrentSetting = function() + return EID.Config["DisplayCraneInfo"] + end, + Display = function() + local onOff = "False" + if EID.Config["DisplayCraneInfo"] then + onOff = "True" + end + return "Crane Game Infos: " .. onOff + end, + OnChange = function(currentBool) + EID.Config["DisplayCraneInfo"] = currentBool + end + } + ) + MCM.AddSpace("EID", "Display") -- Spindown Dice results