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

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
Natha
Fast Inserter
Fast Inserter
Posts: 178
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

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

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

Post Reply

Return to “Modding discussion”