Is it possible to check if entity has enough power?
-
- Inserter
- Posts: 30
- Joined: Thu Mar 07, 2019 4:25 pm
- Contact:
Is it possible to check if entity has enough power?
And is it possible to check if it has 100% power? (Modded electric energy interface)
Re: Is it possible to check if entity has enough power?
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.
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.