Scripty time: An automatic light

To make life even more easy, here is one of my popular scripts for you. This script automatically switches on/off the prim’s light feature according to the sim’s daylight state.
Feel free to experiment with it and change it to suit your needs. If you replace the light-code with a SetTexture, you can even make your enviroment change wheither it’s day or night!
Do remember SecondLife only supports the six closest lights to be showing.
For easy copy-pasting I added the script as code below.

// ==============================================
// Just a plain script to brighten and lighten up a prim.
// Detects automatically if it is day or night and sets the prims params with the corresponding state
// * This header must stay with the script                            *
// ==> Script is meant to stay full perm, copyable and TOTALLY FREE <==\\


default // daytime state, sun above horizon
 {
     state_entry()
     {
         llSetTimerEvent(60); // Check every 1 minutes
     }
     
     timer()
     {
         vector sun = llGetSunDirection();  // receive the sun's position
         if (sun.z < 0) // is it below the horizon, giving us night ?
         {
            llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,TRUE]);
            llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,    // False, light is on
                                    <1.0,0.92,0.68>, // light color vector range: 0.0-1.0 *3
                                    1.0,             // intensity    (0.0-1.0)
                                    8.0,             // radius       (.1-10.0)
                                    0.25 ]);         // falloff      (.01-1.0)
             state night;
         }
     }
     touch_start(integer total_number)
     {
         llWhisper(0, "It's daytime."); //in case you didn't notice ;)
     }
 }
 
 state night // night state, sun below horizon
 {
     state_entry()
     {
         llSetTimerEvent(60); // Check every 1 minute
     }
     timer()
     {
         vector sun = llGetSunDirection(); // receive the sun's position
         if (sun.z > 0) // is it above the horizon, giving us day ?
         {
             llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,FALSE]);
             llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE,   // False, light is off
                                     <0.0,1.0,0.0>,   // light color vector range: 0.0-1.0 *3
                                     1.0,             // intensity    (0.0-1.0)
                                     8.0,             // radius       (.1-10.0)
                                     0.25]);          // falloff      (.01-1.0)
             state default; // Change back to daytime state
         }
     }
     touch_start(integer total_number)
     {
         llWhisper(0, "It's nighttime."); // in case you didn't notice ;)
     }
 }