Read style protoype properties at runtime
Posted: Fri Sep 26, 2025 9:07 am
prototypes.style only allows accessing the type of the style, which isn't very useful. LuaStyle returns nil when reading "default" properties, ones that have not been overwritten. This means that to read the actual properties of styles, using ModData is needed, which comes with all of its flaws - no guarantee that other mods haven't made modifications after reading it, and having to convert between different formats, as the type of properties differ between prototypes and LuaStyles.
Since changing prototypes.style would be a breaking change, reading values from LuaStyle could be changed to return default properties if that property hasn't been overridden. While would be better, this doesn't need to follow the full hierarchy, just the property defined in that style, though in that case LuaStyle.parent would be useful, so the mod can still follow it, by having elements with that parent style. Or if there are other ways this could be implemented, it would be good too.
Since changing prototypes.style would be a breaking change, reading values from LuaStyle could be changed to return default properties if that property hasn't been overridden. While would be better, this doesn't need to follow the full hierarchy, just the property defined in that style, though in that case LuaStyle.parent would be useful, so the mod can still follow it, by having elements with that parent style. Or if there are other ways this could be implemented, it would be good too.