From 3620f6250e57bf185dcca0b531cbeabf0b82f1d2 Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Mon, 3 Jun 2024 19:41:18 +0200 Subject: [PATCH] Fixed error with some search queries with no results --- eid_api.lua | 11 +---------- eid_bagofcrafting.lua | 7 +++++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index 1ba1e73d..0f953034 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -491,6 +491,7 @@ function EID:getDescriptionEntry(objTable, objID, noFallback) else return (translatedTable and translatedTable[objID]) or (EID.descriptions["en_us"][objTable] and EID.descriptions["en_us"][objTable][objID]) end end end + function EID:getDescriptionEntryEnglish(objTable, objID) if not objID then return EID.descriptions["en_us"][objTable] @@ -511,16 +512,6 @@ function EID:getDescriptionData(Type, Variant, SubType) return moddedDesc or legacyModdedDescription or defaultDesc end -function EID:getDescriptionDataEnglish(Type, Variant, SubType) - local fullString = Type.."."..Variant - local adjustedID = EID:getAdjustedSubtype(Type, Variant, SubType) - local moddedDesc = EID:getDescriptionEntryEnglish("custom", fullString.."."..adjustedID) - local tableName = EID:getTableName(Type, Variant, SubType) - local legacyModdedDescription = EID:getLegacyModDescription(Type, Variant, adjustedID) - local defaultDesc = EID:getDescriptionEntryEnglish(tableName, adjustedID) - - return moddedDesc or legacyModdedDescription or defaultDesc -end -- Returns an adjusted SubType id for special cases like Horse Pills and Golden Trinkets function EID:getAdjustedSubtype(Type, Variant, SubType) diff --git a/eid_bagofcrafting.lua b/eid_bagofcrafting.lua index 9140c7d2..c710a30d 100644 --- a/eid_bagofcrafting.lua +++ b/eid_bagofcrafting.lua @@ -1307,15 +1307,18 @@ function EID:handleBagOfCraftingRendering(ignoreRefreshRate) if EID:BoCSGetSearchEnabled() then -- Filter out item names that don't match our search term for _,id in ipairs(sortedIDs) do - local searchValid = #currentRecipesList[id] > 0 and (not EID:BoCSGetSearchEnabled() or EID:BoCSCheckItemName(EID:getDescriptionData(5, 100, id)[2])) + local searchValid = #currentRecipesList[id] > 0 and EID:BoCSCheckItemName(EID:getObjectName(5, 100, id)) if (searchValid) then table.insert(IDsToCheck, id) end end -- Nothing in our recipe list passed the test; try checking English names as a backup if #IDsToCheck == 0 then + local curLang = EID:getLanguage() + EID.Config["Language"] = "en_us" for _,id in ipairs(sortedIDs) do - local searchValid = not EID:BoCSGetSearchEnabled() or EID:BoCSCheckItemName(EID:getDescriptionDataEnglish(5, 100, id)[2]) + local searchValid = EID:BoCSCheckItemName(EID:getObjectName(5, 100, id)) if (searchValid) then table.insert(IDsToCheck, id) end end + EID.Config["Language"] = curLang end else IDsToCheck = sortedIDs end