HOME PRODUCTS HELP FREEBIES SCRIPTS TUTORIALS NEWS CONTACT
  Teleport to Store in-world!    |     Links  
Main Menu
Alicia's Raffle
Who's Online
5 user(s) are online (1 user(s) are browsing Free Scripts)

Members: 0
Guests: 5

more...
Admin Login
Username:

Password:


Lost Password?

Register now!
SL Books


Sites of Interest
Published Date: 2010/5/12 0:16:41
Views : 124
Time

Keeps track if the sun in a region is day or night.

You can use this script to turn a light on automatically when it becomes night time and off in the day. Just add your script snippets where it says "Do something here" below.

integer time = 120; //How many seconds between checking
integer IsDay;

Check()
{
    vector sun_dir = llGetSunDirection(); //gets sun direction

    if (sun_dir.z > 0 && IsDay == FALSE) //a positive value for sun_dir.z means its daytime
    {
        IsDay = TRUE;
        //Do something here for when it is day.
    }
    else if (sun_dir.z < 0 && IsDay == TRUE) //a negative value for sun_dir.z means its nighttime
    {
        IsDay = FALSE;
        //Do something here for when it is night.
    }
}

default
{
    on_rez(integer start_param)
    {
        llResetScript();
    }
    
    state_entry()
    {
        vector sun_dir = llGetSunDirection();
        IsDay = (sun_dir.z < 0);
        Check();
        llSetTimerEvent(time);
    }

    timer()
    {
        Check(); //this calls the function to check the day / night status
    }

    touch_start(integer total_number) //only for debug - can be removed
    {
        Check();
        if (IsDay == TRUE)
        {
            llSay(0, "It is currently day.");
        }
        else
        {
            llSay(0, "It is currently night.");
        }
    }
}

0
|  Links 
Printer Friendly Page Send this Script to a Friend
Visit ASD Studios Hollywood
Product Spotlight
Alicia's Universe
Recent Scripts
Suggested Reading
Top Free Scripts

© 2006-2010 Alicia Stella | ASD Affiliate Programs | Policies | News | Help
Second Life®, Xstreet & the inSL logo are registered trademarks of Linden Research, Inc.
Alicia Stella Design is not affiliated with Second Life. No infringement is intended.