Fixed some situations where the bag of crafting content isnt tracked correctly

This commit is contained in:
Wofsauge committed 2021-06-13 22:49:04 +02:00
1 parent 896141c5e2
commit fe7891aa74
2 files changed
+23 -5

No files matched your search

+22 -2
View File
@@ -288,7 +288,8 @@ function EID:getBagOfCraftingID(Variant, SubType)
return nil return nil
end end
function EID:calculateBagOfCrafting(components) function EID:calculateBagOfCrafting(componentsTable)
local components = {table.unpack(componentsTable)}
if components == nil or #components ~= 8 then if components == nil or #components ~= 8 then
return 0 return 0
end end
@@ -431,13 +432,24 @@ EID:AddCallback(ModCallbacks.MC_POST_ENTITY_REMOVE, function(_, bag)
if bag.Variant ~= 4 or bag.SubType ~= 4 then if bag.Variant ~= 4 or bag.SubType ~= 4 then
return return
end end
table.sort(pickupsOnInit, function (a,b)
return
a:GetSprite():GetFrame() > b:GetSprite():GetFrame() or
(a:GetSprite():GetFrame() == b:GetSprite():GetFrame() and a.Index < b.Index)
end)
for _,e in ipairs (pickupsOnInit) do for _,e in ipairs (pickupsOnInit) do
if e:GetSprite():GetAnimation() == "Collect" then if e:GetSprite():GetAnimation() == "Collect" then
local craftingIDs = EID:getBagOfCraftingID(e.Variant, e.SubType) local craftingIDs = EID:getBagOfCraftingID(e.Variant, e.SubType)
if craftingIDs ~= nil then if craftingIDs ~= nil then
for _,v in ipairs(craftingIDs) do for _,v in ipairs(craftingIDs) do
if #EID.BagItems >= 8 then if #EID.BagItems >= 8 then
table.remove(EID.BagItems, 1) local newContent = {}
for i=2,#EID.BagItems do
table.insert(newContent, EID.BagItems[i])
end
EID.BagItems = newContent
end end
table.insert(EID.BagItems, v) table.insert(EID.BagItems, v)
end end
@@ -508,6 +520,14 @@ end
function EID:handleBagOfCraftingRendering() function EID:handleBagOfCraftingRendering()
trackBagHolding() trackBagHolding()
detectBagContentShift() detectBagContentShift()
if EID.Config["DisplayBagOfCrafting"] == "never" then
return false
end
if EID.Config["DisplayBagOfCrafting"] == "hold" and not string.find(EID.player:GetSprite():GetAnimation(), "PickupWalk") then
return false
end
local results = {} local results = {}
local floorItems = {} local floorItems = {}
local pickups = Isaac.FindByType(5, -1, -1, true, false) local pickups = Isaac.FindByType(5, -1, -1, true, false)
+1 -3
View File
@@ -484,15 +484,13 @@ local function onRender(t)
else else
EID:removeTextPosModifier("Tained HUD") EID:removeTextPosModifier("Tained HUD")
end end
if EID.player:HasCollectible(710) and EID.Config["DisplayBagOfCrafting"] ~= "never" then if EID.player:HasCollectible(710) then
if EID.Config["DisplayBagOfCrafting"] == "always" or (EID.Config["DisplayBagOfCrafting"] == "hold" and string.find(EID.player:GetSprite():GetAnimation(), "PickupWalk")) then
local success = EID:handleBagOfCraftingRendering() local success = EID:handleBagOfCraftingRendering()
if success then if success then
return return
end end
end end
end end
end
if EID.isDisplayingPermanent and EID.permanentDisplayTextObj ~= nil then if EID.isDisplayingPermanent and EID.permanentDisplayTextObj ~= nil then
EID:printDescription(EID.permanentDisplayTextObj) EID:printDescription(EID.permanentDisplayTextObj)