Page 1 of 1

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

Posted: Mon Apr 14, 2025 7:56 pm
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 :)

A way to get entity status diode color

Posted: Wed Jul 23, 2025 1:19 pm
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

Re: A way to get entity status diode color

Posted: Wed Jul 23, 2025 2:49 pm
by curiosity