// 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();
    }
}