Poll

Pole

|
1 (12.5%)
|
1 (12.5%)
|
3 (37.5%)
|
1 (12.5%)
|
2 (25%)

Total Members Voted: 8

Author Topic: Schedule Help  (Read 823 times)

Here's something I worked up, I am unfamiliar on how to do schedules so tell me what to fix.
Code: [Select]
package DayAndNight
{
schedule(240000, 0, Time4, %obj);
{
function Time4(%obj)
{
new Sky(Sky) {
position = "336 136 0";
rotation = "0 0 1 0";
scale = "1 1 1";
materialList = "base/data/skies/Sky_Default/resource.dml";
cloudHeightPer[0] = "0.0";
cloudHeightPer[1] = "0.0";
cloudHeightPer[2] = "0.0";
cloudSpeed1 = "0.0";
cloudSpeed2 = "0.0";
cloudSpeed3 = "0.0";
visibleDistance = "750";
fogDistance = "500"
fogColor = "0.000000 0.000000 0.100000 1.000000";
fogStorm1 = "0";
fogStorm2 = "0";
fogStorm3 = "0";
fogVolume1 = "0 0 0";
fogVolume2 = "0 0 0";
fogVolume3 = "0 0 0";
fogVolumeColor1 = "128.000000 128.000000 128.000000 0.000000";
fogVolumeColor2 = "128.000000 128.000000 128.000000 0.000000";
fogVolumeColor3 = "128.000000 128.000000 128.000000 0.000000";
windVelocity = "0 0 0";
windEffectPrecipitation = "1";
SkySolidColor = "0.000000 0.000000 0.200000 1.000000";
useSkyTextures = "0";
renderBottomTexture = "0";
noRenderBans = "0";
}
}
}
This isn't all, it basically repeats like that with the activatepackage at the end.
« Last Edit: November 28, 2010, 09:22:23 PM by Jasa 12265 »

Schedule is like echo(), it doesn't define a block of code. Put the schedule() line outside of the package or inside of a function, and don't put a set of {}s after it.

I tried
Code: [Select]
package DayAndNight
{
schedule(240000)
function Time4(%obj)
{
new Sky(Sky) {
position = "336 136 0";
rotation = "0 0 1 0";
scale = "1 1 1";
materialList = "base/data/skies/Sky_Default/resource.dml";
cloudHeightPer[0] = "0.0";
cloudHeightPer[1] = "0.0";
cloudHeightPer[2] = "0.0";
cloudSpeed1 = "0.0";
cloudSpeed2 = "0.0";
cloudSpeed3 = "0.0";
visibleDistance = "750";
fogDistance = "500"
fogColor = "0.000000 0.000000 0.100000 1.000000";
fogStorm1 = "0";
fogStorm2 = "0";
fogStorm3 = "0";
fogVolume1 = "0 0 0";
fogVolume2 = "0 0 0";
fogVolume3 = "0 0 0";
fogVolumeColor1 = "128.000000 128.000000 128.000000 0.000000";
fogVolumeColor2 = "128.000000 128.000000 128.000000 0.000000";
fogVolumeColor3 = "128.000000 128.000000 128.000000 0.000000";
windVelocity = "0 0 0";
windEffectPrecipitation = "1";
SkySolidColor = "0.000000 0.000000 0.200000 1.000000";
useSkyTextures = "0";
renderBottomTexture = "0";
noRenderBans = "0";
}
}
But that didn't work. Anything about the ;'s?
« Last Edit: November 28, 2010, 09:57:57 PM by Jasa 12265 »

Put it inside time4, give it an actual function to call, a ; after the } on the new sky and the package, but not the function.

try
function name(%argument)
{
 //stuff
 schedule(delay, 0, name, %argument);
}
(for the function)

Code: [Select]
package DayAndNight
{
function Time4(%obj)
{
new Sky(Sky) {
position = "336 136 0";
rotation = "0 0 1 0";
scale = "1 1 1";
materialList = "base/data/skies/Sky_Default/resource.dml";
cloudHeightPer[0] = "0.0";
cloudHeightPer[1] = "0.0";
cloudHeightPer[2] = "0.0";
cloudSpeed1 = "0.0";
cloudSpeed2 = "0.0";
cloudSpeed3 = "0.0";
visibleDistance = "750";
fogDistance = "500";
fogColor = "0.000000 0.000000 0.100000 1.000000";
fogStorm1 = "0";
fogStorm2 = "0";
fogStorm3 = "0";
fogVolume1 = "0 0 0";
fogVolume2 = "0 0 0";
fogVolume3 = "0 0 0";
fogVolumeColor1 = "128.000000 128.000000 128.000000 0.000000";
fogVolumeColor2 = "128.000000 128.000000 128.000000 0.000000";
fogVolumeColor3 = "128.000000 128.000000 128.000000 0.000000";
windVelocity = "0 0 0";
windEffectPrecipitation = "1";
SkySolidColor = "0.000000 0.000000 0.200000 1.000000";
useSkyTextures = "0";
renderBottomTexture = "0";
noRenderBans = "0";
schedule(240000, 0, Time4, %obj);
};
}
Still not working.

try lowering the time on it (the 240000), as it might be too high, i think there is a limit of 30000 or 60000, although maybe it's higher

Also, you put it in the new(){};, swap it and the line below it.

Got it working, now I'll just have to wait for the schedules to see if it's "Working".
« Last Edit: November 29, 2010, 12:05:37 AM by Jasa 12265 »

try lowering the time on it (the 240000), as it might be too high, i think there is a limit of 30000 or 60000, although maybe it's higher
I can't lower it, that's 4 minutes right?

You need to move the schedule call outside the part that creates the new sky:

Code: [Select]
package DayAndNight
{
function Time4(%obj)
{
.................
renderBottomTexture = "0";
noRenderBans = "0";
};
schedule(240000, 0, "Time4", %obj);
}

however -- this will create an endless loop.  make sure thats what you want.

You can't put a schedule directly in a package.
1 million and up are converted to scientific notation as soon as you do any math on them, and schedule won't accept them like that. I think that if you write the number directly, schedule will accept larger numbers than 1000000.

Schedule is a function that schedules a function to be called a certain number of ms in the future. It cannot be put in a package (I think), it can not define a block of code, if you want something to repeat every # ms, it must schedule itself every time it runs.

Red_Guy: You missed some indentation.

Code: [Select]
package DayAndNight
{
function Time4(%obj)
{
.................
renderBottomTexture = "0";
noRenderBans = "0";
};
schedule(240000, 0, "Time4", %obj);
}
};

I would write something like this:
Code: [Select]
function changeSky(%number)
{
    switch(%number)
    {
        case 0:
          ... //Set a dawn sky
        case 1:
          ... //Set a day sky
        case 2:
          ... //Set a sunset sky
        case 3:
          ... //Set a night sky
    }
    schedule(300000, 0, changeSky, (%number + 1) % 4);
}
changeSky(0);

If only one or two values differ between the skies, I would put that sets the sky after the switch, and it would use variables set within the switch(). Less code duplication that way.

Code: [Select]
function changeSky(%num) {
switch(%num) {
case 0:
... //Set a dawn sky
case 1:
... //Set a day sky
case 2:
... //Set a sunset sky
case 3:
... //Set a night sky
}
schedule(300000, 0, changeSky, (%num + 1 => 4 ? 0 : %num + 1));
}
changeSky(0);

The above would work, minus that there's no code setting for the cases. Your code would return 0.25 in the second cycle, thus breaking the script.

% is the modulo operator, not division.

% is the modulo operator, not division.

%    (Modulus) Computes the integer remainder of dividing 2 numbers.

Bigger explanation, please...