Page 1 of 1
control.lua get power environment?
Posted: Wed Jul 22, 2015 12:44 pm
by iUltimateLP
Hi guys, is it possible to check with the control.lua if a entity has power around him and if yes how much (with around him i mean if its in the range of any electric pole)..
I have my teleporter right now, but I dont find the right class to use. If I put it as a decorative everything works except the animations, but a decorative does not need any power, so if its not possible via the script, which class I can use?
Thanks!
Re: control.lua get power environment?
Posted: Wed Jul 22, 2015 1:08 pm
by Klonan
Hmm i think you could use something like
Code: Select all
local poles = {}
poles = game.find_entities_filtered{area = {{X -5, Y - 5 }, {X + 5 , Y + 5 }}, name= "medium-electric-pole"}
if poles[1].energy > 0 then do stuff
Re: control.lua get power environment?
Posted: Wed Jul 22, 2015 1:10 pm
by iUltimateLP
Klonan wrote:Hmm i think you could use something like
Code: Select all
local poles = {}
poles = game.find_entities_filtered{area = {{X -5, Y - 5 }, {X + 5 , Y + 5 }}, name= "medium-electric-pole"}
if poles[1].energy > 0 then do stuff
Well ok, I should think more
Thanks!
Re: control.lua get power environment?
Posted: Wed Jul 22, 2015 5:46 pm
by Ranakastrasz
While no way to hook into the power network without searching an entire power network exists that I know of, having your unit be an accumulator, or using a dummy-accumulator (ghost collision mask, no sprite) and setting it's energy to some amount below 100% would let you draw power from a network.
A non-ghost version is in the Forcefield walls mod.
https://forums.factorio.com/forum/vie ... =14&t=6862
The forcefield spawner is an accumulator itself, which can only charge, but not discharge, and a script takes power from it as requested, followed by it drawing more power.