Read style protoype properties at runtime

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Osmo
Fast Inserter
Fast Inserter
Posts: 156
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Read style protoype properties at runtime

Post 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.
User avatar
Osmo
Fast Inserter
Fast Inserter
Posts: 156
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: Read style protoype properties at runtime

Post by Osmo »

To show the problem, these are all the properties:
изображение.png
изображение.png (96.65 KiB) Viewed 135 times
This is what mods see:
изображение.png
изображение.png (3.73 KiB) Viewed 135 times
Bilka
Factorio Staff
Factorio Staff
Posts: 3647
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Read style protoype properties at runtime

Post by Bilka »

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.
User avatar
Osmo
Fast Inserter
Fast Inserter
Posts: 156
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: Read style protoype properties at runtime

Post 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.
Post Reply

Return to “Modding interface requests”