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!
control.lua get power environment?
-
- Long Handed Inserter
- Posts: 66
- Joined: Sun May 24, 2015 4:41 pm
- Contact:
Re: control.lua get power environment?
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
-
- Long Handed Inserter
- Posts: 66
- Joined: Sun May 24, 2015 4:41 pm
- Contact:
Re: control.lua get power environment?
Well ok, I should think more Thanks!Klonan wrote:Hmm i think you could use something likeCode: 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
- Ranakastrasz
- Smart Inserter
- Posts: 2125
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: control.lua get power environment?
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.
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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16