Author Topic: Alright modders, rally up! What are we gonna do about callbackless daycycles?  (Read 982 times)

So there's a bigass problem with V21: No callbacks when night turns to day/day to night.
I mean, I've read posts that people are so happy that Badspot "finally is helping the modders!" because he added Game Modes.

Yeah, Game Modes are nice. No, they aren't motherloving daycycles. We were promised shadows, shaders, and daycycles. Where is my modding support for those?

Now, I've done a bunch of research on this subject alone with tree() and dump() and frankly, I've got a bit of info but I can't piece it together.


Alright, for starters, here's an example taken out of the default daycycle file.

Code: [Select]
FRACTION 0.0576022
DIRECTCOLOR 0.601383 0.621495 0.455957 1.000000
AMBIENTCOLOR 0.334940 0.434579 0.282273 1.000000
SKYCOLOR 0.361953 0.562198 0.691589 1.000000
FOGCOLOR 0.631374 0.733645 0.589658 1.000000
SHADOWCOLOR 0.152153 0.289428 0.485981 1.000000
SUNFLARECOLOR 0.641643 0.663551 0.328675 1.000000

What can we glean from this? I'll summarize.
First line is fraction, this tells the system what part of the whole cycle this should be at. For example, the above suggests that at 5% of the way through the cycle, it will show the above settings applied to the sun, sky, fog, and shadows.

How does this work on our end? After all, that isn't a nice prefs.cs or anything that actually defines variables, right? Wrong.

DayCycle.dump(); suggests that the system applies the above information as "member fields" to the DayCycle simObject in the form of an array.

Here's the above excerpt, taken from the game.
Code: [Select]
targetAmbientColor[1] = "85 111 72 255"
targetDirectColor[1] = "153 158 116 255"
targetFogColor[1] = "161 187 150 255"
targetFraction[1] = "0.0576022"
targetShadowColor[1] = "39 74 124 255"
targetSkyColor[1] = "92 143 176 255"
targetSunFlareColor[1] = "164 169 84 255"
targetUseDefaultVector[1] = "0"

What does this tell us? Well, obviously these values are accessable from ingame. Obviously we can loop through them, because they are an array.

But do they help us in any way? forget no!

See, I've dreamt up a few ways to try to approach the onDay and onNight events/callback system.
Among my ideas were the following.
onDay and onNight callbacks, as I was under the mistaken impression we were promised? // BUSTED, there are none!

Perhaps set schedules, based on the dayLength in seconds setting? // BUSTED! Thanks to that amazingly beautiful system so that updates a propagated immediately, you can't get a good fix on this. Your schedules will be offset.

Perhaps loop through the default.daycycle settings to compare the settings to the current values of the sun, when they equal, it's that time of day? // BUSTED! You can't actually get the dynamic settings of the sun. You can only get the static settings, which are defined by those loving slider bars in the envGui.


So, what do we do? We can't latch onto DayCycle.dayLength with schedules, as there is nothing to check against.
There are no default callbacks.
You can't get the current values of the current position of the sun and such during a daycycle, it only returns the static settings.



What the hell do we do, coding help?
« Last Edit: August 10, 2012, 05:03:20 PM by Lugnut »

Yea that was me and my post. Sorry everyone

Figure out the variable for day/nighcycle length, and figure out how to start a schedule loop that will be triggered after that time, but be update if someone changes the cycle time.

Figure out the variable for day/nighcycle length, and figure out how to start a schedule loop that will be triggered after that time, but be update if someone changes the cycle time.
Done, done, can't be done.

Here's why: When you update the cycle time, the cycle starts, most of the time, from where it left off.
Note the "most of the time". The other less-than-most of the time, it starts from noon. I cannot reproduce either.

Couldn't you just make your own day/night functionality?

Couldn't you just make your own day/night functionality?
i get the feeling this would be a lot of work

but this would definitely be more complete... hmmmmmmmmm..... you have a good idea there.

Here's why: When you update the cycle time, the cycle starts, most of the time, from where it left off.
getsimtime()-$CallbackLoopStartTime


breaking news: the game logs the time you started.. something. i need to check what it uses as an index


but

when you change the time on a daycycle, eg, from 30 to 300...

lets do this like this

if you start at the length of 30 seconds, and it goes 15 seconds in, it'll show you night.

now, if you change it to 60 seconds, it'll still be 15 seconds in, but the sun will jump to noon!

possibly based on sim time.
possibly based on when you first checked the "enable daycycle" box
« Last Edit: August 10, 2012, 05:25:30 PM by Lugnut »

i hate math :(
Subtract the start time from the current time, then get the total length of a cycle starting from noon and subtract the previous answer.

So new-(now-start)

now, if you change it to 60 seconds, it'll still be 15 seconds in, but the sun will jump to noon!
er okay
« Last Edit: August 10, 2012, 05:28:52 PM by Ipquarx »

Would like to be able to help here D:
But my craptop can't even run shaders fff

Boring stuff graphics for the next week until I get home D:

On a 30 second loop...

Code: [Select]
function getCurrentDayTime()
{
%currentTime = getSimTime();

%len = DayCycle.dayLength;

%currentTime = %currentTime / 1000;

echo(%currentTime / %len);
}
This function echoes a number, which, when it is a number with no decimal points (whole number?), a new day starts.

Basically, whenever getSimTime returns [AnyNumbersHere]000, it's dawn.
Whenever it returns [numbers]500, it's dusk.

Let me go make a proof of concept.

So basically  if((%currentTime % %dayLengh) == 0){doStuff();} ?
If your code is right that works

So basically  if((%currentTime % %dayLengh) == 0){doStuff();} ?
If your code is right that works
yeah, I was just thinking this.
more like this, actually.
if(mFloor(%currentTime % %len) == 0){doStuff();}


because of the ungodly spare stuff

yeah just tested your method, not flawless, testing mine
« Last Edit: August 10, 2012, 06:58:04 PM by Lugnut »

What does mFloor do again

Doesn't it mess this up?