From b7a28b873943b6f44c2a1a6838c3e3e8bd0dc27b Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Thu, 21 Oct 2021 00:58:37 +0200 Subject: [PATCH] Improved colors and code of new item unlock-state functions --- eid_api.lua | 14 +++----------- eid_bagOfCrafting.lua | 23 ++++++----------------- eid_data.lua | 3 +++ 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index 462c70c8..80891061 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -751,12 +751,11 @@ end -- Converts a given CollectibleID into the respective Spindown dice result function EID:getSpindownResult(collectibleID) - local config = Isaac.GetItemConfig() local newID = collectibleID repeat newID = newID - 1 --note: the order of the SkipLocked check statement is important so that the item is checked for being in a pool either way (to display a ? if it isn't) - until (config:GetCollectible(newID) and (EID:isCollectibleUnlockedAnyPool(newID) or not EID.Config["SpindownDiceSkipLocked"]) and not config:GetCollectible(newID).Hidden) or newID == CollectibleType.COLLECTIBLE_NULL + until (EID.itemConfig:GetCollectible(newID) and (EID:isCollectibleUnlockedAnyPool(newID) or not EID.Config["SpindownDiceSkipLocked"]) and not EID.itemConfig:GetCollectible(newID).Hidden) or newID == CollectibleType.COLLECTIBLE_NULL return newID end @@ -764,7 +763,7 @@ function EID:GetMaxCollectibleID() local id = CollectibleType.NUM_COLLECTIBLES-1 local step = 16 while step > 0 do - if Isaac.GetItemConfig():GetCollectible(id+step) ~= nil then + if EID.itemConfig:GetCollectible(id+step) ~= nil then id = id + step else step = step // 2 @@ -784,7 +783,6 @@ function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem) itemPool:AddRoomBlacklist(i) end end - local room = Game():GetRoom() local isUnlocked = false for i = 0,1 do -- some samples to make sure local collID = itemPool:GetCollectible(itemPoolOfItem, false) @@ -798,35 +796,29 @@ function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem) end function EID:isCollectibleUnlockedAnyPool(collectibleID) - local itemConfig = Isaac.GetItemConfig() - local item = itemConfig:GetCollectible(collectibleID) + local item = EID.itemConfig:GetCollectible(collectibleID) if EID.itemUnlockStates[collectibleID] == nil then --whitelist all quest items and items with no associated achievement if (item.AchievementID == -1 or item.Tags & ItemConfig.TAG_QUEST == ItemConfig.TAG_QUEST) then - --print("item " .. tostring(collectibleID) .. " is tagged as quest or has no achievement ID!") EID.itemUnlockStates[collectibleID] = true return true end --blacklist all hidden items if (item.Hidden) then - --print("item " .. tostring(collectibleID) .. " is tagged as hidden!") EID.itemUnlockStates[collectibleID] = false return false end --iterate through the pools this item can be in for k,v in ipairs(EID.CollectiblesPools[collectibleID]) do if (EID:isCollectibleUnlocked(collectibleID, v)) then - --print("found item " .. tostring(collectibleID) .. " unlocked in pool " .. tostring(v)) EID.itemUnlockStates[collectibleID] = true return true end end --note: some items will still be missed by this, if they've been taken out of their pools (especially when in Greed Mode) - --print("couldn't find item " .. tostring(collectibleID) .. " in any item pools") EID.itemUnlockStates[collectibleID] = false return false else - --print("item " .. tostring(collectibleID) .. " was already cached: " .. tostring(EID.itemUnlockStates[collectibleID])) return EID.itemUnlockStates[collectibleID] end end diff --git a/eid_bagOfCrafting.lua b/eid_bagOfCrafting.lua index a6cb192b..b6966f3d 100644 --- a/eid_bagOfCrafting.lua +++ b/eid_bagOfCrafting.lua @@ -760,11 +760,9 @@ function EID:handleBagOfCraftingRendering() --fix bug with being allowed to go to an empty page if recipe count = multiple of page size (or if we refresh on last page) if (EID.bagOfCraftingOffset >= #results) then EID.bagOfCraftingOffset = EID.bagOfCraftingOffset - EID.Config["BagOfCraftingResults"] end - local resultCount = 0 - local skips = 0 local prevItem = 0 - local qualities = { [0] = "{{ColorSilver}}", "{{ColorLime}}", "{{ColorTransform}}", "{{ColorObjName}}", "{{ColorGold}}" } + local qualities = { [0] = "{{ColorSilver}}", "{{ColorLime}}", "{{ColorPastelBlue}}", "{{ColorLavender}}", "{{ColorLightOrange}}" } local prefix = "#{{Blank}} " if (EID.lockedResults) then prefix = "#{{Trinket159}} " @@ -776,17 +774,17 @@ function EID:handleBagOfCraftingRendering() end for i=EID.bagOfCraftingOffset+1,EID.bagOfCraftingOffset+EID.Config["BagOfCraftingResults"] do local v = results[i] - if (not v) then break end + if not v then break end - if (not EID.Config["BagOfCraftingDisplayNames"]) then + if not EID.Config["BagOfCraftingDisplayNames"] then customDescObj.Description = customDescObj.Description.."# {{Collectible"..v[2].."}} " --tack on Breakfast image to locked recipes - if (v[3]) then customDescObj.Description = customDescObj.Description.."{{Collectible25}}" end + if v[3] then customDescObj.Description = customDescObj.Description.."({{Collectible25}})" end --color the equals sign with the item quality, so the order of the list can make sense customDescObj.Description = customDescObj.Description.. qualities[EID.itemWeightsLookup[v[2]]] .. "={{CR}}" --only display the item name if it's the first occurrence else - if (prevItem ~= v[2]) then + if prevItem ~= v[2] then --substring the first 18 characters of the item name so it fits on one line; is there a way to get around desc line length limits? customDescObj.Description = customDescObj.Description.."# {{Collectible"..v[2].."}} ".. qualities[EID.itemWeightsLookup[v[2]]] .. string.sub(EID:getObjectName(5, 100, v[2]),1,18).."#" @@ -794,7 +792,7 @@ function EID:handleBagOfCraftingRendering() customDescObj.Description = customDescObj.Description.."#" end --replace recipe bulletpoint with Breakfast on locked recipes - if (v[3]) then customDescObj.Description = customDescObj.Description.." {{Collectible25}} " end + if v[3] then customDescObj.Description = customDescObj.Description.." {{Collectible25}} " end end customDescObj.Description = customDescObj.Description..EID:tableToCraftingIconsMerged(v[1]) @@ -807,12 +805,3 @@ function EID:handleBagOfCraftingRendering() EID:printDescription(customDescObj) return true end - ---[[ -Isaac.DebugString("Calculating: {1, 1, 1, 1, 1, 1, 1, 1}") -Isaac.DebugString(EID:calculateBagOfCrafting({1, 1, 1, 1, 1, 1, 1, 1})) -Isaac.DebugString("Calculating: {1, 1, 1, 1, 1, 1, 1, 2}") -Isaac.DebugString(EID:calculateBagOfCrafting({1, 1, 1, 1, 1, 1, 1, 2})) -Isaac.DebugString("Calculating: {1, 1, 1, 1, 1, 1, 1, 3}") -Isaac.DebugString(EID:calculateBagOfCrafting({1, 1, 1, 1, 1, 1, 1, 3})) -]]-- diff --git a/eid_data.lua b/eid_data.lua index 365c70bc..ba977a19 100644 --- a/eid_data.lua +++ b/eid_data.lua @@ -291,6 +291,9 @@ EID.InlineColors = { ["ColorTeal"] = KColor(0, 0.5, 0.5, 1), ["ColorNavy"] = KColor(0, 0, 0.5, 1), ["ColorOrange"] = KColor(1, 0.54, 0, 1), + ["ColorPastelBlue"] = KColor(0.3882, 0.5216, 1, 1), + ["ColorLavender"] = KColor(0.7451, 0.3686, 1, 1), + ["ColorLightOrange"] = KColor(1, 0.6353, 0.3686, 1), -- Swag Colors -- Rainbow color effect