Forcing Lamp state

Place to get help with not working mods / modding interface.
Eonasdan
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat May 07, 2016 4:45 pm
Contact:

Forcing Lamp state

Post by Eonasdan »

I'm trying to force a lamp to turn on based on some conditions. I've tried several things without success.

I've tried setting the circuit network to a always true condition (e.g. item = 0). I've tried forcing it to connect to itself. Even with the "currentCodition.fulfilled" as true it doesn't turn on. Interestingly, if I manually connect it to a near by power pole it turns on, however I really want to avoid this.

I couldn't locate a method or function that turns it on/off.

Code: Select all

local currentCondition = data.entity.get_circuit_condition(defines.circuitconditionindex.lamp)
data.entity.connect_neighbour({
	wire = defines.circuitconnector.red,
	target_entity = data.entity,
	source_circuit_id = 1,
	target_circuit_id = 1,
})
if currentCondition.condition.comparator ~= "=" then

currentCondition.condition.first_signal = {name = "coal", type="item"}
debugLog(currentCondition.condition.first_signal.name)

debugLog(currentCondition.condition.constant)
currentCondition.condition.constant = 0
debugLog(currentCondition.condition.constant)

debugLog(currentCondition.fulfilled)

data.entity.set_circuit_condition(defines.circuitconditionindex.lamp, {condition={comparator="=",
								 first_signal={type="item", name="coal"},
								 constant=0}})
end
currentCondition = data.entity.get_circuit_condition(defines.circuitconditionindex.lamp)
debugLog(currentCondition.fulfilled)
Any idea's?
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Forcing Lamp state

Post by aubergine18 »

I'm having similar issue - I'm making a radio mast and I want a few lamps on the mast (like IRL), but I want them to be on/off by scripting, not just day/night cycle. For example, one lamp should only come on when mast is transmitting.

I'm thinking maybe an approach like Nixie Tubes mod - using masks... but I have no idea how to do that yet. From what I can see the nixie tubes mod actually uses a vehicle for the tubes, which bakes my brain.

If anyone knows a way to do it, please let us know!
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
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Forcing Lamp state

Post by DaveMcW »

Eonasdan wrote:Interestingly, if I manually connect it to a near by power pole it turns on, however I really want to avoid this.
The lamp has 2 modes, circuit and day/night. If you connect it to anything (even another lamp), you can control it with circuit code. If it is disconnected, it follows the day/night cycle and you can't do anything to control it.

If you are really opposed to connecting it, you have to use a different entity.
Post Reply

Return to “Modding help”