max collectible ID function

This commit is contained in:
Buurazu authored and GitHub committed 2021-10-19 22:15:13 -04:00
1 parent f00322d656
commit 744b4c3291
1 file changed
+23 -7
+23 -7
View File
@@ -759,10 +759,26 @@ function EID:getSpindownResult(collectibleID)
return newID return newID
end end
function EID: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 maxCollectibleID = nil
function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem) function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem)
local itemPool = Game():GetItemPool() local itemPool = Game():GetItemPool()
local itemConfig = Isaac.GetItemConfig() local itemConfig = Isaac.GetItemConfig()
for i= 1, GetMaxCollectibleID() do if (not maxCollectibleID) then maxCollectibleID = EID:GetMaxCollectibleID() end
for i= 1, maxCollectibleID do
if ItemConfig.Config.IsValidCollectible(i) and i ~= collectibleID then if ItemConfig.Config.IsValidCollectible(i) and i ~= collectibleID then
itemPool:AddRoomBlacklist(i) itemPool:AddRoomBlacklist(i)
end end
@@ -822,21 +838,21 @@ end
-- Converts a given table into a string containing the crafting icons of the table, which are also grouped to reduce render lag -- Converts a given table into a string containing the crafting icons of the table, which are also grouped to reduce render lag
-- Example input: {1,1,1,2,2,3,3,3} -- Example input: {1,1,1,2,2,3,3,3}
-- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}" -- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}"
local emptyPickupTable = {}
for i=1,25 do emptyPickupTable[i] = 0 end
function EID:tableToCraftingIconsMerged(craftTable) function EID:tableToCraftingIconsMerged(craftTable)
local sortedList = {table.unpack(craftTable)} local sortedList = {table.unpack(craftTable)}
table.sort(sortedList, function(a, b) return a > b end) table.sort(sortedList, function(a, b) return a > b end)
local filteredList = {} local filteredList = {table.unpack(emptyPickupTable)}
for _,nr in ipairs(sortedList) do for _,nr in ipairs(sortedList) do
if filteredList[nr] == nil then
filteredList[nr] = 1
else
filteredList[nr] = filteredList[nr] +1 filteredList[nr] = filteredList[nr] +1
end end
end
local iconString = "" local iconString = ""
for nr,count in pairs(filteredList) do for nr,count in ipairs(filteredList) do
if (count > 0) then
iconString = iconString..count.."{{Crafting"..nr.."}}" iconString = iconString..count.."{{Crafting"..nr.."}}"
end end
end
return iconString return iconString
end end