Simple Prim Lighting

// Simple lighting (prim glow) script
//
// Lighting toggled on touch.
//
// For a version of this script that includes remote switching
// and multi-prim switching functionality, see:
// http://kimmscripts.wordpress.com/2011/11/23/simple-remote-lighting/
//
// Kimm Paulino
// January 2012
 
// Properties of the light you may wish to change
// ----------------------------------------------------
// LIGHT = TRUE or FALSE - turns the light on or off (lights contribute to lag in SL)
integer LIGHT = TRUE;
 
// BRIGHT = TRUE or FALSE - turns brightness on or off (less laggy than lights)
integer BRIGHT = TRUE;
 
// GLOW = Range 0.0 to 1.0 - dim to full glow
float GLOW = 1.0;
 
// See: http://lslwiki.net/lslwiki/wakka.php?wakka=color
vector COLOUR = <1 .0, 1.0, 1.0>;
 
// Intensity of the radiated light - range 0.0 to 1.0
float INTENSITY = 1.0;    
 
// Radius of the radiated light (in metres) - range 0.1 to 20.0
float RADIUS = 5.0;
 
// Rate light decays - range 0.01 to 2.0 (no decay to quick decay)
float FALLOFF = 0.5;
 
// See: http://wiki.secondlife.com/wiki/Face
integer FACE = ALL_SIDES;
// ----------------------------------------------------
 
integer gOn = FALSE;
 
on ()
{
    // Turn on to the required settings
    llSetPrimitiveParams([
            PRIM_POINT_LIGHT, LIGHT, COLOUR, INTENSITY, RADIUS, FALLOFF,
            PRIM_FULLBRIGHT, FACE, BRIGHT,
            PRIM_GLOW, FACE, GLOW
            ]);
}
 
off ()
{
    llSetPrimitiveParams([
            PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.0, 0.0, 0.0,
            PRIM_FULLBRIGHT, FACE, FALSE,
            PRIM_GLOW, FACE, FALSE
            ]);
}
 
performLightCmd ()
{
    if (gOn)
    {
        off();
        gOn = FALSE;
    }
    else
    {
        on();
        gOn = TRUE;
    }
}
 
default
{
    on_rez (integer start_param)
    {
        llResetScript();
    }
 
    state_entry ()
    {
        gOn = FALSE;
    }
 
    touch_start (integer num_detected)
    {
        performLightCmd();
    }
}

 

Add a comment

Remote Light

Great remote with menu for a light switch.

Light:

vector red = <0.86,0.0,0.14>; 
vector green  = <0,0.9,0>; 
vector white  = <1 ,1,1>;
vector black  = <0.12,0.1,0.12>;
vector steel  = <0.27,0.51,0.71>;
vector blue  = <0.1,0.31,0.98>;
vector orange  = <1 ,.6,0>;
vector yellow  = <1 ,1,0.1>;
vector brown  = <0.5,0.25,0>;
vector pink  = <0.85,0,0.75>;
vector purple  = <0.8,0.21,0.8>;
vector lime  = <0.18,0.75,0.34>;
vector sky  = <0.53,0.81,0.92>;
vector lavander  = <0.2,0.2,0.4>;

default
{
    state_entry()
    {
                llSetStatus(STATUS_PHANTOM, TRUE);
 llListen(788, "", NULL_KEY, "" );
    }
    
    on_rez(integer num)
    {
        llResetScript();
    }

    listen(integer number, string name, key id, string message)
    {        //--------------LightEffects----------
       
                     if(message=="redl")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, red, 1.0, 20.0, 0.75]);
}
                     if(message=="greenl")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, green, 1.0, 20.0, 0.75]);
}
                     if(message=="whitel")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, white, 1.0, 20.0, 0.75]);
}
                     if(message=="blackl")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, black, 1.0, 20.0, 0.75]);
}
                     if(message=="steell")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, steel, 1.0, 20.0, 0.75]);
}
                     if(message=="bluel")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, blue, 1.0, 20.0, 0.75]);
}
                     if(message=="orangel")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, orange, 1.0, 20.0, 0.75]);
}
                     if(message=="yellowl")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, yellow, 1.0, 20.0, 0.75]);
}
                     if(message=="brownl")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, brown, 1.0, 20.0, 0.75]);
}
                     if(message=="pinkl")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, pink, 1.0, 20.0, 0.75]);
}
                     if(message=="purplel")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, purple, 1.0, 20.0, 0.75]);
}
                     if(message=="limel")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, lime, 1.0, 20.0, 0.75]);
}
                     if(message=="skyl")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, sky, 1.0, 20.0, 0.75]);
}
                     if(message=="lavanderl")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, lavander, 1.0, 20.0, 0.75]);
}

                     if(message=="off")
        {
 llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0,0,0>, 1.0, 0.0, 0.0]);
}      
        

        }

}

Remote:

integer menu_handler;
integer menu_channel;

menu(key user,string title,list buttons)//make dialog easy, pick a channel by itself and destroy it after 5 seconds
{
    menu_channel = (integer)(llFrand(99999.0) * -1);//yup a different channel at each use
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,buttons,menu_channel);
    llSetTimerEvent(5.0);
}

default
{state_entry()
    { llSetTouchText("Remote!");
    }
    touch_start(integer t)
    {
        menu(llDetectedKey(0),"Choose a color from the List below...",["white","red","green","blue","steel","orange","yellow","pink","purple","sky","lavander","OFF"]);
    }
    timer() //so the menu timeout and close its listener
    {
        llSetTimerEvent(0.0);
        llListenRemove(menu_handler);
    }
    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel) //in case you have others listeners
        {
           integer c_channel = 788;//-----THIS IS THE CHANNEL FOR COMMANDS----
            if(message == "white")
            {
        llShout(c_channel, "whitel");
            }
            else if(message == "red")
            {
        llShout(c_channel, "redl");
            }

            else if(message == "green")
            {
        llShout(c_channel, "greenl");
            }        
            else if(message == "blue")
            {
        llShout(c_channel, "bluel");
            }
            else if(message == "black")
            {
        llShout(c_channel, "blackl");
            }                
            else if(message == "steel")
            {
        llShout(c_channel, "steell");
            }
            else if(message == "orange")
            {
        llShout(c_channel, "orangel");        
            }
            else if(message == "yellow")
            {
        llShout(c_channel, "yellowl");                                
            }
            else if(message == "purple")
            {
        llShout(c_channel, "purplel");                                                                      }                                                              
            else if(message == "pink")
            {
        llShout(c_channel, "pinkl");                                                                      }                 
            else if(message == "lime")
            {
        llShout(c_channel, "limel");                                                                      }                         
            else if(message == "sky")
            {
        llShout(c_channel, "skyl");                                                                      }                                 
            else if(message == "lavander")
            {
        llShout(c_channel, "lavanderl");                                                                      }        
                                  else if(message == "OFF")
            {
        llShout(c_channel, "off");                                                                                                
                                                                 
        }
    }
}}

 

Add a comment

Red Flashing Light Script

// Creates slow, red, flashing light effect.

default {
    state_entry() {
        llParticleSystem
        ([
            PSYS_PART_FLAGS,
            PSYS_PART_INTERP_COLOR_MASK|
            PSYS_PART_FOLLOW_SRC_MASK|
            PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN,
            PSYS_SRC_PATTERN_ANGLE_CONE,
            PSYS_SRC_INNERANGLE, 0.0,
            PSYS_SRC_OUTERANGLE, 0.1,
            PSYS_SRC_BURST_SPEED_MIN, 0.0,
            PSYS_SRC_BURST_SPEED_MAX, 0.0,
            PSYS_SRC_BURST_RADIUS, 0.0,
            PSYS_SRC_BURST_PART_COUNT, 5,
            PSYS_SRC_BURST_RATE, 1.0,
            PSYS_PART_MAX_AGE, 1.0,
            PSYS_PART_START_SCALE, <1 ,1,1>,
            PSYS_PART_START_COLOR, <1 ,0.2,0.2>,
            PSYS_PART_END_COLOR, <1 ,0,0>,
            PSYS_PART_START_ALPHA, 1.0,
            PSYS_PART_END_ALPHA, 0.0
        ]);
    }
}

 

Add a comment

Touch for Illumination Off-Low-Medium-High-Off

// Touch for Illumination Lo-Med-Hi-OFF
//
// Insouciant Yue  November 2007
//
// This script will look up the existing settings of a prim, and then respond to
// Touch by changing the illumination level OFF->Lo->Med->Hi->OFF
// actually, we will force the Light feature ON, keeping the existing settings,
// and simply toggle through the illumination level (which is set 0.0 to 1.0) 
// at 0.0 (same as OFF), 0.33, 0.67, and 1.0 (full ON)
//
// If this is put into a root prim of a linked object, then touching the object anywhere
// (on any of its prims) will change the illumination level of the prim the script is in


vector colour;        // colour of prim lighting
float intensity;    // illumination level
float radius;        // radius of light
float falloff;        // falloff of light

default
{   
    on_rez(integer dummy)
    {
        list params = llGetPrimitiveParams([PRIM_POINT_LIGHT]);
            colour = llList2Vector(params, 1);
            intensity = llList2Float(params, 2);
            radius = llList2Float(params, 3);
            falloff = llList2Float(params, 4);

        llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE,    // Force illumination ON
            colour,
            1.0,                    // Force full illumination
            radius,
            falloff ]);
    }

    touch_start(integer dummy)
    {
        // these probably haven't changed, but just in case the user is manually
        // editing the prim's Light feature parameters, let's get them anyway.
        list params = llGetPrimitiveParams([PRIM_POINT_LIGHT]);
            colour = llList2Vector(params, 1);
            intensity = llList2Float(params, 2);
            radius = llList2Float(params, 3);
            falloff = llList2Float(params, 4);

        intensity = intensity + 0.333;        // bump to next level by "1/3rd light level"

        if (intensity > 1.0)
            intensity = 0.0;    // roll around after full on (1.0) to zero

        llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE,    // Force illumination ON
            colour,
            intensity,                // Force new illumination level
            radius,
            falloff ]);
       
       }
}

 

Add a comment

Light Switch

integer lightMasterChannel = 4874320;
integer channel = 4445566;
integer gLightOn = 0;
vector onCol = <1 .0, 1.0, 0.5>;
vector offCol = <0.2, 0.2, 0.2>;

turnOn()
{
        llSetColor(onCol, ALL_SIDES);
        gLightOn = 1;
        llWhisper(channel, "on");
}

turnOff()
{
        llSetColor(offCol, ALL_SIDES);
        gLightOn = 0;
        llWhisper(channel, "off");    
}

flicker()
{
    integer x;
    for (x = 0; x <5; x++)
    {
        if (gLightOn) turnOff();
        else turnOn();
        llSleep(llFrand(2));
    }
}
        

default
{
    state_entry()
    {
        llListen(lightMasterChannel, "", "", "");
        llPassTouches(TRUE);
    }

    touch_end(integer total_number)
    {
        if (gLightOn == 0)
        {
            turnOn();
        }
        else
        {
            turnOff();
        }
    }
    
    listen(integer channel, string who, key id, string msg)
    {
        if (msg == "on")
        {
            llSleep(llFrand(8));
            flicker();
            turnOn();
        }
        else if (msg == "off")
        {
            llSleep(llFrand(8));
            flicker();
            turnOff();
        }
    }

}

 

Add a comment