Basic Light Switch ( V1 )

Written by Kitsune

Placed in the root of a linked object this script will make the whole object active to touch. The light will always be emitted by the prim the script is in. So, if you have a 5 prim lamp, put this in the "bulb" prim and make that prim the root. If placed in a child prim of an object, only that prim will be clickable (unless there are other touch scripts in other prims of the object).

 

 

// V1 //
 
vector color = <1.0, 1.0, 1.0>; // R,G,B (red, green, blue) values.
 
float intensity = 1.0;          // 0.0 to 1.0 (1.0 = full brightness)
 
float radius = 20.0;            // 0.1 to 20.0 (20.0 = full sphere)
 
float falloff = 0.01;           // 0.01 to 2.0 (2.0 = least spread)
 
/////////////////////////////////////////////////////////////////////////
 
integer on; // Global variable used to measure the condition 'on or off'.
 
Switch() // The switching function.
{
    on = (!on); // Flip the boolean value of the integer 'on'.
    llSetPrimitiveParams([PRIM_POINT_LIGHT, on, color, intensity, radius, falloff]);
}
 
default
{
    touch_end(integer nd)
    {
        Switch(); // Unconditionally call the switch to operate.
    }
}