From d2bf2bc4b9076be1d597dbc570a0ae2c9c80a280 Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Sun, 13 Jun 2021 23:09:36 +0200 Subject: [PATCH] Adds fail check to bag of crafting to prevent calculations when modded items are enabled --- descriptions/rep/en_us.lua | 1 + eid_bagOfCrafting.lua | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/descriptions/rep/en_us.lua b/descriptions/rep/en_us.lua index 6d3eb933..5582dab1 100644 --- a/descriptions/rep/en_us.lua +++ b/descriptions/rep/en_us.lua @@ -670,4 +670,5 @@ EID.descriptions["en_us"].horsepills={ EID.descriptions["en_us"].CraftingBagContent = "Pickups in bag:" EID.descriptions["en_us"].CraftingRoomContent = "Pickups in room:" EID.descriptions["en_us"].CraftingResults = "Results:#(Scroll: Hold TAB + Shoot △/▽)" +EID.descriptions["en_us"].CraftingBagModError = "!!! {{ColorRed}}ERROR:#{{ColorRed}}This feature currently does not support games with modded items installed" diff --git a/eid_bagOfCrafting.lua b/eid_bagOfCrafting.lua index b7d3efe0..2b602c86 100644 --- a/eid_bagOfCrafting.lua +++ b/eid_bagOfCrafting.lua @@ -517,6 +517,34 @@ local function toggleControls(value) end end +local function GetMaxCollectibleID() + local id = CollectibleType.NUM_COLLECTIBLES-1 + local step = 16 + while step > 0 do + if Isaac.GetItemConfig():GetCollectible(id+step) ~= nil then + id = id + step + else + step = step // 2 + end + end + + return id +end +local maxItemID = nil + +local function detectModdedItems() + if maxItemID == nil then + maxItemID = GetMaxCollectibleID() + end + if maxItemID > CollectibleType.NUM_COLLECTIBLES then + local customDescObj = EID:getDescriptionObj(5, 100, 710) + customDescObj.Description = EID.descriptions["en_us"].CraftingBagModError + EID:printDescription(customDescObj) + return true + end + return false +end + function EID:handleBagOfCraftingRendering() trackBagHolding() detectBagContentShift() @@ -527,6 +555,9 @@ function EID:handleBagOfCraftingRendering() if EID.Config["DisplayBagOfCrafting"] == "hold" and not string.find(EID.player:GetSprite():GetAnimation(), "PickupWalk") then return false end + if detectModdedItems() then + return false + end local results = {} local floorItems = {}