From c6215f624f19ba879aa96aa932e7a04d957f9a3c Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Sat, 5 Jun 2021 01:57:00 +0200 Subject: [PATCH] Made golden trinkets compatible with description modifiers --- eid_api.lua | 8 ++++++-- eid_modifiers.lua | 14 ++++++++++++++ main.lua | 9 --------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index c41119ca..0745713e 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -362,7 +362,11 @@ end -- Returns an adjusted SubType id for special cases like Horse Pills and Golden Trinkets function EID:getAdjustedSubtype(Type, Variant, SubType) local tableName = EID:getTableName(Type, Variant, SubType) - if tableName == "pills" or tableName == "horsepills" then + if tableName == "trinkets" then + if SubType > 32768 then + return SubType - 32768 + end + elseif tableName == "pills" or tableName == "horsepills" then if SubType == 14 then return 9999 end @@ -420,8 +424,8 @@ end -- tries to get the ingame name of an item based on its ID function EID:getObjectName(Type, Variant, SubType) - local tableEntry = EID:getDescriptionData(Type, Variant, SubType) local tableName = EID:getTableName(Type, Variant, SubType) + local tableEntry = EID:getDescriptionData(Type, Variant, EID:getAdjustedSubtype(Type, Variant, SubType)) local name = nil if tableEntry ~= nil then if tableEntry[2] ~= nil and tableEntry[2] ~= "" and tableEntry[2] ~= EID.descriptions["en_us"][tableName][SubType] then diff --git a/eid_modifiers.lua b/eid_modifiers.lua index 177e4fde..cafe138c 100644 --- a/eid_modifiers.lua +++ b/eid_modifiers.lua @@ -115,4 +115,18 @@ local game = Game() EID:addDescriptionModifier("Tarot Cloth", TarotClothCondition, TarotClothCallback) + + -- Handle Golden Trinket description addition + local function GoldenTrinketCondition(descObj) + return descObj.ObjType == 5 and descObj.ObjVariant == PickupVariant.PICKUP_TRINKET and descObj.ObjSubType > TrinketType.TRINKET_GOLDEN_FLAG + end + + local function GoldenTrinketCallback(descObj) + local goldenDesc = EID:getDescriptionEntry("goldenTrinket") or "" + descObj.Description = "{{ColorGold}}"..goldenDesc.."#"..descObj.Description + return descObj + end + EID:addDescriptionModifier("Tarot Cloth", GoldenTrinketCondition, GoldenTrinketCallback) + + end \ No newline at end of file diff --git a/main.lua b/main.lua index f87c0bee..000a5652 100644 --- a/main.lua +++ b/main.lua @@ -559,16 +559,7 @@ local function onRender(t) if closest.Variant == PickupVariant.PICKUP_TRINKET then --Handle Trinkets local trinketID = closest.SubType - local isGoldenTrinket = false - if trinketID > 32768 then - trinketID = trinketID - 32768 - isGoldenTrinket = true - end local descriptionObj = EID:getDescriptionObj(closest.Type, closest.Variant, trinketID) - if isGoldenTrinket then - local goldenDesc = EID:getDescriptionEntry("goldenTrinket") or "" - descriptionObj.Description = "{{ColorGold}}"..goldenDesc.."#"..descriptionObj.Description - end EID:printDescription(descriptionObj) elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then --Handle Collectibles