Added modular description system (limited scope to 170 fully automateable items)
This commit is contained in:
1 parent
411be3d8a7
commit
d98397ec26
27 files changed
+3807
-3
No files matched your search
+45
-2
@@ -639,8 +639,18 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity, checkModifiers)
|
||||
description.Name = EID:getObjectName(Type, Variant, SubType)
|
||||
description.Entity = entity or nil
|
||||
|
||||
local tableEntry = EID:getDescriptionData(Type, Variant, SubType)
|
||||
description.Description = tableEntry and tableEntry[3] or EID:getXMLDescription(Type, Variant, SubType)
|
||||
local generatedModularDesc = false
|
||||
if EID.FullyAutomatedDescriptions[description.fullItemString] then
|
||||
local success, modularDescription = pcall(EID.GenerateDescription, nil, description)
|
||||
if success and modularDescription and modularDescription ~= "" then
|
||||
description.Description = modularDescription
|
||||
generatedModularDesc = true
|
||||
end
|
||||
end
|
||||
if not generatedModularDesc then
|
||||
local tableEntry = EID:getDescriptionData(Type, Variant, SubType)
|
||||
description.Description = tableEntry and tableEntry[3] or EID:getXMLDescription(Type, Variant, SubType)
|
||||
end
|
||||
|
||||
description.Transformation = EID:getTransformation(Type, Variant, SubType)
|
||||
|
||||
@@ -1625,6 +1635,39 @@ function EID:removeDescriptionModifier(modifierName)
|
||||
end
|
||||
end
|
||||
|
||||
---Adds Modular data modifier
|
||||
---@param modifierName string
|
||||
---@param condition fun(descObj: EID_DescObj): boolean
|
||||
---@param callback fun(descObj: EID_DescObj): EID_DescObj
|
||||
---@param position? integer
|
||||
function EID:addModularDataModifier(modifierName, condition, callback, position)
|
||||
position = position or #EID.ModularDataModifiers + 1
|
||||
for _, v in ipairs(EID.ModularDataModifiers) do
|
||||
if v["name"] == modifierName then
|
||||
v["condition"] = condition
|
||||
v["callback"] = callback
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(EID.ModularDataModifiers, position, {
|
||||
name = modifierName,
|
||||
condition = condition,
|
||||
callback = callback
|
||||
})
|
||||
end
|
||||
|
||||
---Removes a Modular data modifier
|
||||
---@see EID.addModularDataModifier
|
||||
---@param modifierName string
|
||||
function EID:removeModularDataModifier(modifierName)
|
||||
for i, v in ipairs(EID.ModularDataModifiers) do
|
||||
if v["name"] == modifierName then
|
||||
table.remove(EID.ModularDataModifiers, i)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Interpolates between 2 KColors with a given fraction.
|
||||
---@param kColor1 KColor
|
||||
---@param kColor2 KColor
|
||||
|
||||
Reference in new issue
Block a user