Add PlanetPrototype.LightningProperties.start_time and end_time

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
snouz
Inserter
Inserter
Posts: 45
Joined: Sun Jan 03, 2021 6:01 pm
Contact:

Add PlanetPrototype.LightningProperties.start_time and end_time

Post by snouz »

Hi, I'm trying to create a new sort of lightning strikes (solar flares) and I searched everywhere how to make the lightning strike when the sun is up, which I can't find neither in LightningPrototype, nor LightningProperties. Lightning will always strike at night.

My suggestion would be to have a start_time and end_time in LightningProperties, that go from 0 to 1 (like day_night_cycle_color_lookup)
Planet Moshine, GUI Unifier + 17 mods, contributed graphically and otherwise to 70+ mods
Schaniqua
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri May 09, 2025 8:14 pm
Contact:

Re: Add PlanetPrototype.LightningProperties.start_time and end_time

Post by Schaniqua »

+1

This would be a good addition as well, have the lightning active time be customisable over the span of the day
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3883
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Add PlanetPrototype.LightningProperties.start_time and end_time

Post by boskid »

Currently amount of lightnings generated is based on the surface's darkness - its not quite the same as LuaSurface::darkness because the darkness used for lightnings is not capped by a value set by LuaSurface::min_brightness. Primary issue is that right now the darkness is 0 at day and 1 at night with a gradual change on the dusk-evening transition and on the dawn-morning transition. Having straight set of start_time and end_time is not enough to preserve transitions as they are right now and if i cannot make a change to be backwards compatible with existing mods i am not going to add it.
curiosity
Filter Inserter
Filter Inserter
Posts: 636
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Add PlanetPrototype.LightningProperties.start_time and end_time

Post by curiosity »

Then add the same four-point system you use for the daytime: dusk/dawn/evening/morning. Which, by the way, should be bundled in a table. Changing only one rarely makes sense, but trying to change them one by one olny ever causes problems.
User avatar
snouz
Inserter
Inserter
Posts: 45
Joined: Sun Jan 03, 2021 6:01 pm
Contact:

Re: Add PlanetPrototype.LightningProperties.start_time and end_time

Post by snouz »

boskid wrote: Sat May 10, 2025 9:00 am Currently amount of lightnings generated is based on the surface's darkness - its not quite the same as LuaSurface::darkness because the darkness used for lightnings is not capped by a value set by LuaSurface::min_brightness. Primary issue is that right now the darkness is 0 at day and 1 at night with a gradual change on the dusk-evening transition and on the dawn-morning transition. Having straight set of start_time and end_time is not enough to preserve transitions as they are right now and if i cannot make a change to be backwards compatible with existing mods i am not going to add it.
Ah yes I understand, thanks for looking at this.

I didn't know that was progressive and tied to the darkness property (which could be de-hardcoded as well I think), so I have another proposition:

- Have the same kind of table as for color lookup:

Code: Select all

planet.lightning_properties.timed_intensity = {
        {0.0,  0},
        {0.35, 0.5},
        {0.40, 0.7},
        {0.85, 0},
},
(first column is time of day, second is intensity)
Planet Moshine, GUI Unifier + 17 mods, contributed graphically and otherwise to 70+ mods
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3883
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Add PlanetPrototype.LightningProperties.start_time and end_time

Post by boskid »

curiosity wrote: Sat May 10, 2025 11:59 am Which, by the way, should be bundled in a table. Changing only one rarely makes sense, but trying to change them one by one olny ever causes problems.
I see. That is a reasonable modding interface request, independent of this topic. Ability to change all 4 daytime points is implemented for 2.0.48 as LuaSurface::daytime_parameters read/write.
preview
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3883
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Add PlanetPrototype.LightningProperties.start_time and end_time

Post by boskid »

From possible options, i think the most easy for me to implement would be to add SurfacePropertyID into LightningProperties - if it would be set, then amount of lightnings would be controlled by that surface property. This value could then be set by PlanetPrototype::surface_properties or set/changed at runtime using LuaSurface::set_property. That would however require mods to adjust surface properties each tick if a more interesting daytime profile is needed. Would that be acceptable?
Schaniqua
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri May 09, 2025 8:14 pm
Contact:

Re: Add PlanetPrototype.LightningProperties.start_time and end_time

Post by Schaniqua »

Would it be possible to decouple the lightning from the daytime completely as an option?
I dream of it like this, have the following parameters

Planet surface setting:
- Lightning_coupled_to_nighttime: true/false
Default true, decides whether base model like it is right now is used OR:
- Lightning_Intensity: 0-1 (?) mandatory parameter if above is false, sets lightning intensity as is. Make this accessible at runtime.

(Maybe i understand it wrong but on second read you are basically suggesting a lightning_intensity option at runtime right?)

This would also allow lightning storms / freak lightning events etc without changing the surface daytime.

Also probably out of scope and discussed here viewtopic.php?p=671447#p671447 but related to the mechanic:
My only other wish would be to be able to set the endangered_by_lightning warning icon to a different one if the lightning_properties define another icon rather than the default one. Also being able to turn it off at runtime for a machine, so if the lightning mechanic is a event the warning icon isnt always blinking.

Im not deep in the lua code so i hope this isnt too outlandish, thank you for checking my suggestion out, have a great day!
Post Reply

Return to “Modding interface requests”