Is it possible to check if entity has enough power?

Place to get help with not working mods / modding interface.
Post Reply
Romner_set
Inserter
Inserter
Posts: 30
Joined: Thu Mar 07, 2019 4:25 pm
Contact:

Is it possible to check if entity has enough power?

Post by Romner_set »

And is it possible to check if it has 100% power? (Modded electric energy interface)

User avatar
Arcitos
Inserter
Inserter
Posts: 38
Joined: Sat Dec 03, 2016 1:50 pm
Contact:

Re: Is it possible to check if entity has enough power?

Post by Arcitos »

You might use the "energy" property of the electric interface to check for this: If its > 0, the interface is at least somewhat powered.

If you want to check whether a certain treshold is reached (e.g. "at least 60% of energy demand provided"), your calculation could take the "power_usage" into account: energy / power_usage is the ratio of available energy to energy demand (e.g.: if its > 0.6, your threshold is reached). But I didn't test this beforehand. Please note, that "power_usage" is using energy standard units like "kW" and needs to be converted to Joule beforehand.

Post Reply

Return to “Modding help”