From 802fe2514f6eaeef07258f1b2de15f05a96abf90 Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Fri, 4 Jun 2021 21:26:07 +0200 Subject: [PATCH] Improved bag of crafting reset and navigation detection --- eid_api.lua | 2 +- eid_bagOfCrafting.lua | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index 9e6a262f..845e189a 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -357,7 +357,7 @@ function EID:getAdjustedSubtype(Type, Variant, SubType) return 9999 end local pool = game:GetItemPool() - SubType = pool:GetPillEffect(SubType, Isaac.GetPlayer(0)) + 1 + SubType = pool:GetPillEffect(SubType, EID.player) + 1 end return SubType end diff --git a/eid_bagOfCrafting.lua b/eid_bagOfCrafting.lua index 80a4124a..bb3d12a5 100644 --- a/eid_bagOfCrafting.lua +++ b/eid_bagOfCrafting.lua @@ -448,13 +448,15 @@ end, EntityType.ENTITY_KNIFE) local holdCounter = 0 local function trackBagHolding() local isCardHold = Input.IsActionPressed(ButtonAction.ACTION_PILLCARD, 0) - if isCardHold and string.match(Isaac.GetPlayer(0):GetSprite():GetAnimation(), "PickupWalk") and #EID.BagItems>=8 then + local animationName = EID.player:GetSprite():GetAnimation() + if isCardHold and string.match(animationName, "PickupWalk") and #EID.BagItems>=8 then holdCounter = holdCounter + 1 - if holdCounter >= 55 then - EID.BagItems = {} - end else - holdCounter = 0 + if isCardHold and holdCounter >= 30 and string.match(animationName, "Walk") and not string.match(animationName, "Pickup") then + EID.BagItems = {} + else + holdCounter = 0 + end end end @@ -486,6 +488,17 @@ EID.bagOfCraftingCurPickupCount = -1 EID.bagOfCraftingLastQuery = {} EID.BagItems = {} +local isControlsBlocked = false + +local function toggleControls(value) + if not value then + EID.player.ControlsEnabled = false + isControlsBlocked = false + elseif not isControlsBlocked and value then + EID.player.ControlsEnabled = true + isControlsBlocked = false + end +end function EID:handleBagOfCraftingRendering() trackBagHolding() @@ -518,6 +531,7 @@ function EID:handleBagOfCraftingRendering() end -- Calculate result from pickups on floor if #itemQuery < 8 then + toggleControls(true) return false end table.sort(itemQuery, function(a, b) return a > b end) @@ -552,6 +566,7 @@ function EID:handleBagOfCraftingRendering() if #results == 0 then EID.bagOfCraftingOffset = 0 + toggleControls(true) return false end @@ -559,7 +574,12 @@ function EID:handleBagOfCraftingRendering() local roomDesc = EID.descriptions[EID.Config["Language"]].CraftingRoomContent or EID.descriptions["en_us"].CraftingRoomContent local bagContentDesc = EID.descriptions[EID.Config["Language"]].CraftingBagContent or EID.descriptions["en_us"].CraftingBagContent local resultDesc = EID.descriptions[EID.Config["Language"]].CraftingResults or EID.descriptions["en_us"].CraftingResults - customDescObj.Description = bagContentDesc.."#"..EID:tableToCraftingIconsMerged(EID.BagItems).."#" + local bagContentResult = "" + if #EID.BagItems >= 8 then + local recipe = EID:calculateBagOfCrafting(EID.BagItems) + bagContentResult = "{{Collectible"..recipe.."}} " + end + customDescObj.Description = bagContentDesc.." (Beta)#"..bagContentResult..EID:tableToCraftingIconsMerged(EID.BagItems).."#" customDescObj.Description = customDescObj.Description ..roomDesc.."#"..EID:tableToCraftingIconsMerged(floorItems).."#"..resultDesc if Input.IsActionPressed(ButtonAction.ACTION_MAP, 0) or Input.IsActionPressed(ButtonAction.ACTION_MAP, 1) then @@ -568,9 +588,9 @@ function EID:handleBagOfCraftingRendering() elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTUP, 0) or Input.IsActionTriggered(ButtonAction.ACTION_SHOOTUP, 1) then EID.bagOfCraftingOffset = math.max(0, EID.bagOfCraftingOffset - EID.Config["BagOfCraftingResults"]) end - Isaac.GetPlayer(0).ControlsEnabled = false + toggleControls(false) else - Isaac.GetPlayer(0).ControlsEnabled = true + toggleControls(true) end local resultCount = 0