Made golden trinkets compatible with description modifiers

This commit is contained in:
Wofsauge committed 2021-06-05 01:57:00 +02:00
1 parent 009da2d876
commit c6215f624f
3 files changed
+20 -11

No files matched your search

+6 -2
View File
@@ -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
+14
View File
@@ -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
-9
View File
@@ -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