Rework Unidentified Pill eval, to allow Description modifiers when unidentified

This commit is contained in:
Wofsauge committed 2023-10-08 16:54:53 +02:00
1 parent 34b7c2a8dc
commit c3c8710617
2 files changed
+33 -18

No files matched your search

+18 -12
View File
@@ -395,18 +395,7 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity, checkModifiers)
EID:getObjectItemTypeAndCharge(description)
if checkModifiers ~= false then
for _,modifier in ipairs(EID.DescModifiers) do
local result = modifier.condition(description)
if type(result) == "table" then
for _,callback in ipairs(result) do
-- If the modifier loads a different description obj (which also goes through the modifier checks), we should stop our checks so text doesn't get printed twice
if description.ObjSubType ~= SubType then break end
description = callback(description)
end
elseif result then
description = modifier.callback(description)
end
end
description = EID:applyDescriptionModifier(description, SubType)
end
return description
end
@@ -429,6 +418,23 @@ function EID:getLegacyModDescription(Type, Variant, SubType)
return nil
end
-- apply Description Modifier to a given description object
function EID:applyDescriptionModifier(description, SubType)
for _,modifier in ipairs(EID.DescModifiers) do
local result = modifier.condition(description)
if type(result) == "table" then
for _,callback in ipairs(result) do
-- If the modifier loads a different description obj (which also goes through the modifier checks), we should stop our checks so text doesn't get printed twice
if description.ObjSubType ~= SubType then break end
description = callback(description)
end
elseif result then
description = modifier.callback(description)
end
end
return description
end
-- Returns the icon and mod name of a given EID description object as a preformatted description string
function EID:getModNameString(descObj)
local modString = ""