I'm currently struggling with a script that is executed in the data-final-fixes stage and that should append something to the description of some items.
Code:
Code: Select all
local function append_compostable_description(item_name, humus_count)
local prototype = data.raw.item[item_name]
if not prototype then --item doesn't exist within the loaded mods
return
end
local appendix = {"item-description.compostable", humus_count}
if prototype.localised_description then
prototype.localised_description = {"", prototype.localised_description, "\n", appendix}
elseif prototype.description then
local description = prototype.description
prototype.description = nil
prototype.localised_description = {"", {description}, "\n", appendix}
else
prototype.localised_description = appendix
end
end
I think this is because prototype.localized_description wasn't set in the item's declaration and the factorio engine checks if the localisation files define a description at a later stage.
So I would need to check if "item-description.<item-name>" is defined, as setting it in the declaration isn't possible because some items belong to other mods.
Is there a way to do that?