Page 1 of 1

Read style protoype properties at runtime

Posted: Fri Sep 26, 2025 9:07 am
by Osmo
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.

Re: Read style protoype properties at runtime

Posted: Fri Sep 26, 2025 9:14 am
by Osmo
To show the problem, these are all the properties:
изображение.png
изображение.png (96.65 KiB) Viewed 143 times
This is what mods see:
изображение.png
изображение.png (3.73 KiB) Viewed 143 times

Re: Read style protoype properties at runtime

Posted: Fri Sep 26, 2025 9:38 am
by Bilka
What is your usecase for reading these values?

Re: Read style protoype properties at runtime

Posted: Fri Sep 26, 2025 10:44 am
by Osmo
Bilka wrote: Fri Sep 26, 2025 9:38 am What is your usecase for reading these values?
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.