function to set dawn/dusk/morning/evening all at once

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

function to set dawn/dusk/morning/evening all at once

Post by sparr »

Setting each of these values independently risks triggering the morning<dawn<dusk<evening assertions, even if the values you intend to set them all to are valid in the end. I ended up writing a helper function, but it would be a lot more straightforward if this was built in.

Code: Select all

function set_times(surface, dusk, evening, morning, dawn)
  surface.dusk = 0
  surface.evening = .0000000001
  surface.morning = .0000000002
  surface.dawn = dawn
  surface.morning = morning
  surface.evening = evening
  surface.dusk = dusk
end

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: function to set dawn/dusk/morning/evening all at once

Post by Rseding91 »

I specifically didn't make a function like that because I didn't want to deal with checking all of the input values to be valid against each other :P So, you have to do it on your end and set them in the correct order.
If you want to get ahold of me I'm almost always on Discord.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: function to set dawn/dusk/morning/evening all at once

Post by sparr »

The problem is that there doesn't seem to be a single "correct order" other than the 7-step function I included above. Either the order has to change based on which things you're adjusting in which directions, or you have to make those extra .0000001 etc steps which look silly.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: function to set dawn/dusk/morning/evening all at once

Post by sparr »

As I consider rewriting my mod that changes day/night length over time, I'd really appreciate having this functionality instead of having to work around edge cases.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: function to set dawn/dusk/morning/evening all at once

Post by FuryoftheStars »

Forgive my ignorance, but if it’s already doing assertion checks, then isn’t this essentially the same (or at least half-way there) of the game already “checking all of the input values to be valid against each other”? I’d think the game just having a function for this would make things better?
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

curiosity
Filter Inserter
Filter Inserter
Posts: 322
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: function to set dawn/dusk/morning/evening all at once

Post by curiosity »

Rseding91 wrote:
Wed Mar 28, 2018 8:58 am
I specifically didn't make a function like that because I didn't want to deal with checking all of the input values to be valid against each other :P
Didn't want to deal with checking three conditions for all instead of one or two conditions for each?

Post Reply

Return to “Modding interface requests”