A easy way to read the Condition of a Lamp

Place to get help with not working mods / modding interface.
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 393
Joined: Tue Jul 08, 2014 10:06 am
Contact:

A easy way to read the Condition of a Lamp

Post 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
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: A easy way to read the Condition of a Lamp

Post 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
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 393
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: A easy way to read the Condition of a Lamp

Post by LuziferSenpai »

aubergine18 wrote: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
There i cant get a easy way to read the signal ;) I need to know which Signal is it ;)
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: A easy way to read the Condition of a Lamp

Post 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
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 393
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: A easy way to read the Condition of a Lamp

Post by LuziferSenpai »

aubergine18 wrote: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
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. ^^
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: A easy way to read the Condition of a Lamp

Post 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?
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: A easy way to read the Condition of a Lamp

Post 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
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Post Reply

Return to “Modding help”