Page 1 of 1

api call to get power drawed from electric network

Posted: Wed May 09, 2018 3:26 am
by ownlyme
Hi,
I'm working on an electric interface for my turret energy shields and I want them to loose their energy more quickly, when there is no energy available on the network.
It seems like there is no api to see how much energy the entity actually drains.
When I use is_connected_to_electric_network(), it always returns true as long as there are any power-producers in the network, even if they output nothing, even if they are just empty accumulators.
My request would be to make the function return false if the energy is 0 or very low, or to add a lightweight api call to check how much the entity actually draws from the electric network.

edit: i found a workaround (by caching the stored energy) but still think this should be implemented

Re: api call to get power drawed from electric network

Posted: Fri May 11, 2018 2:43 am
by Rseding91
How much energy an entity draws from the electric network depends on what it's doing that tick. If a crafting machine is running it takes some energy based off beacon effects. If it finished crafting that tick it will take 0 next tick unless it resumes crafting.

You can simply read entity.energy > 0 to see if it has energy.

Re: api call to get power drawed from electric network

Posted: Sun May 13, 2018 9:29 pm
by ownlyme
i know, that's why i said i was calculating the energy from tick to tick.
but i assume that since the energy consumption changes every tick, it might be a bit harder to implement that feature.
but you should totally fix that there is no simple way to see if the entity is in a dead electricity network

Re: api call to get power drawed from electric network

Posted: Mon May 14, 2018 5:38 am
by betrok
ownlyme wrote:but you should totally fix that there is no simple way to see if the entity is in a dead electricity network
Eh? There is a way:
Rseding91 wrote:You can simply read entity.energy > 0 to see if it has energy.
Though it will not take into account the priority.