Page 1 of 1
A easy way to read the Condition of a Lamp
Posted: Thu Sep 22, 2016 3:02 pm
by LuziferSenpai
Hey,
i search for a easy way to get the Condition of a Lamp.
So i mean if it has a Green/Red Wire
Greetz,
Luzifer
Re: A easy way to read the Condition of a Lamp
Posted: Thu Sep 22, 2016 3:19 pm
by aubergine18
The source code for this mod will show you how - look at the on_tick handler in particular.
https://mods.factorio.com/mods/theRusty ... ork-switch
Re: A easy way to read the Condition of a Lamp
Posted: Thu Sep 22, 2016 3:25 pm
by LuziferSenpai
There i cant get a easy way to read the signal

I need to know which Signal is it

Re: A easy way to read the Condition of a Lamp
Posted: Thu Sep 22, 2016 3:27 pm
by aubergine18
Ah, I thought you just wanted to know which color wires were attached.
GotLag's old Wireless mod should show simple example of reading values:
https://mods.factorio.com/mods/GotLag/W ... 20Networks
Re: A easy way to read the Condition of a Lamp
Posted: Thu Sep 22, 2016 3:37 pm
by LuziferSenpai
That is for getting every Signal that this entity gets, but not for reading the Condition of a Lamp, so with Singal is set in the Lamp. ^^
Re: A easy way to read the Condition of a Lamp
Posted: Thu Sep 22, 2016 4:05 pm
by aubergine18
So you want to read the current state of the lamp (is it on or off? what color is it?) and not the signals coming in to it?
Or are you looking for the network conditions defined on the lamp by the player?
Re: A easy way to read the Condition of a Lamp
Posted: Thu Sep 22, 2016 4:10 pm
by aubergine18
I think first you need:
Code: Select all
get_or_create_control_behavior() → LuaControlBehavior
Gets (and or creates if needed) the control behavior of the entity.
Return value
The control behavior or nil.
And then once you have the behaviour you can:
Code: Select all
class LuaLampControlBehavior extends LuaGenericOnOffControlBehavior
use_colors :: boolean [RW] true if the lamp should set the color from the circuit network signals.
valid :: boolean [R] Is this object valid?
Inherited from LuaControlBehavior: get_circuit_network, type, entity
Inherited from LuaGenericOnOffControlBehavior: disabled, circuit_condition, logistic_condition, connect_to_logistic_network