Author Topic: Day/Night Cycle  (Read 907 times)

I wanted to try my hand at making something like this.
How would I get the sun object? Would I have to loop through the mission group and check for each object for the sun or what?
« Last Edit: July 02, 2011, 05:56:16 PM by DYLANzzz »

Code: [Select]
function getSun()
{
    for(%i=0;%i<missionGroup.getCount();%i++)
    {
        %obj = missionGroup.getObject(%i);
        if(%obj.getClassname() $= "Sun")
        {
            %sun = %obj;
            break;
        }
    }
    if(isObject(%sun))
        return %sun;
    return 0;
}
This should only be ran when necessary because it will probably lag some, especially if there are a sizable amount of bricks / other objects. I suggest you run it on a map change or load when there's not many objects left from mission cleanup.
« Last Edit: July 02, 2011, 07:25:50 PM by TripleNickels »

Already been done so why?

You'll find that a large majority (if not all) have the 'sun object' directly named Sun. So you can just use Sun.dostuff();.
What you might want to do for compatability, is check if there is an object called Sun first and if there isn't use TripleNickels method, otherwise just use the Sun object directly.

You'll find that a large majority (if not all) have the 'sun object' directly named Sun. So you can just use Sun.dostuff();.
What you might want to do for compatability, is check if there is an object called Sun first and if there isn't use TripleNickels method, otherwise just use the Sun object directly.
You're thinking of Sky. Sun isn't ever named Sun as far as I've seen.

You're thinking of Sky. Sun isn't ever named Sun as far as I've seen.
Oh yeah sorry, you're right.

Already been done so why?
I already made and released a day/night/weather mod.
Though it could be improved for compatibility.

I already made and released a day/night/weather mod.
Though it could be improved for compatibility.
He's making the sun rotate.

He's making the sun rotate.
Though the sky?
Or like, on its axis?