Expose entities' status diode_color and label even for non-custom states

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
petrathekat
Inserter
Inserter
Posts: 27
Joined: Fri Apr 19, 2024 7:12 pm
Contact:

Expose entities' status diode_color and label even for non-custom states

Post by petrathekat »

Hello,

Right now the only interface modders have to get information about an entity's status is LuaEntity::status, which is just an enum. This means that if you want to render your own diode+label combination, say in a custom GUI for an entity, you have to write a lot of code to figure out the localisation of that status and what sprite to draw.

The code for getting the localisation key has already been posted on the forums: viewtopic.php?p=538298. However it will still be a lot of manual code to associate each status with its correct color sprite, and it's a bunch of unnecessary and error-prone mapping for a value the game already knows.

I suggest adding LuaEntity::status_diode of type defines.entity_status_diode and LuaEntity::status_label of type LocalisedString. But of course you are free to implement whatever interface you wish :)
User avatar
Osmo
Fast Inserter
Fast Inserter
Posts: 156
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

A way to get entity status diode color

Post by Osmo »

There is a way to get the status of an entity, however it returns a defines enum with around 70 values, and its the job of the mod to match it to the corresponding diode color. This is unnecessary work that must be done if the status needs to be displayed anywhere in the mod, especially so given the corresponding colors are not documented, and what i've seen people do is match only the statuses they think the entity can have, which is error prone. I'm asking for a way to match the status to its diode color
curiosity
Filter Inserter
Filter Inserter
Posts: 690
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: A way to get entity status diode color

Post by curiosity »

Post Reply

Return to “Modding interface requests”