I want to write a custom GUI showing entity status of some selected entities.
LuaEntity::status gives enum like "defines.entity_status.item_ingredient_shortage", which will actually be integers.
On the other hand, the text I want to show is located in locale files under [entity-status], like the line "item-ingredient-shortage=Item ingredient shortage".
Here are my questions:
1/ How can I use the value read from LuaEntity::status, to get the corresponding status locale strings?
2/ Is there a function (which I may have overlooked) to achieve Q1?
3/ If No & No to Q1 & Q2. Is there a smarter way than construct my own table for such integer-to-string mapping... I am currently achieving my Q1 by writing a lengthy table (shown below) by using defines.entity_status reference.
Code: Select all
local entity_status = {
[defines.entity_status.working] = { code = 1, desc = "working" },
[defines.entity_status.normal] = { code = 1, desc = "normal" },
[defines.entity_status.no_power] = { code = 3, desc = "no-power" },
[defines.entity_status.low_power] = { code = 2, desc = "low-power" },
[defines.entity_status.no_fuel] = { code = 3, desc = "no-fuel" },
...
}
local status = player.selected.status
local msg = { "entity-status." .. entity_status[status].desc }
local coloridx = entity_status[status]
Thanks for your attention.
Regards,
Schall