Page 1 of 1

How is LuaEntity::energy calculated? Compared to energy_usage and max_energy_usage

Posted: Thu Mar 28, 2024 1:54 pm
by Natha
What is the difference between

Code: Select all

LuaEntityPrototype::max_energy_usage
and

Code: Select all

LuaEntityPrototype::energy_usage
for "normal" consumer entities? They return the same value, which is the maximum power consumption (in W) - drain and divided by 60 (result is Joules per tick).

When calling

Code: Select all

LuaEntity::energy
on a fully powered entity, the value * 60 is higher than the maximum power consumption. How is this calculated?
When not fully powered, the value matches the consumption in the power statistics GUI.

My goal is to retrieve a percentage of available power to that entity.