Page 1 of 1

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

Posted: Wed Mar 28, 2018 3:42 am
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

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

Posted: Wed Mar 28, 2018 8:58 am
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.

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

Posted: Wed Mar 28, 2018 4:02 pm
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.

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

Posted: Wed Aug 24, 2022 3:17 pm
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.

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

Posted: Wed Aug 24, 2022 11:46 pm
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?

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

Posted: Thu Aug 25, 2022 6:47 am
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?