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.
Read style protoype properties at runtime
Re: Read style protoype properties at runtime
To show the problem, these are all the properties:
This is what mods see:
Re: Read style protoype properties at runtime
What is your usecase for reading these values?
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Read style protoype properties at runtime
Modifying the various gui properties in-game as a tool for modders, as i've seen many people having trouble making GUIs. While modifying element properties and copying element styles and style properties work, for modifying the style properties knowning default values is needed.
I started implementing it with the current API, but then more and more problems come up and it would require manually creating even more big lookup tables and logic, while the game already converts most of these things when loading the styles.