Page 1 of 1

How to draw a light only when target entity is powered

Posted: Wed Jun 05, 2019 1:28 am
by ThePlash
Hello!

In my mod I'm adding a technology that makes roboports emit light during the night. To achieve this, I'm using rendering.draw_light() with minimum_darkness = 0.5

Now I need them to stop emitting light if they get disconnected from power. I'm already tracking the ID of the light associated with the roboport, but I have no clue about how to react to a change in their power status (powered to unpowered and vice versa).

Is there a way to do this?

Another idea i have is to use a dummy invisible lamp entity placed over the roboport so I can leverage the lamp logic, but I'm wondering if there's another way that doesn't require spawning an additional entity for each roboport on the map...

Any suggestion?

Thanks!

Re: How to draw a light only when target entity is powered

Posted: Thu Jun 06, 2019 4:42 pm
by eradicator
Spawning extra lamps is way cheaper than on_tick scanning every roboport all the time just to see if it has power. Because that's the only thing you could do.

Re: How to draw a light only when target entity is powered

Posted: Thu Jun 06, 2019 10:56 pm
by ThePlash
eradicator wrote: Thu Jun 06, 2019 4:42 pm Spawning extra lamps is way cheaper than on_tick scanning every roboport all the time just to see if it has power. Because that's the only thing you could do.
Just as i thought... i'll probably go the lamp entity way

Thanks