Tuesday, September 2, 2014

Simple Light on Touch [Level II]

Here's my simple script to switch a light on and off by touch.

In this case touch causes the prim to alternately generate light and extinguish the light. I included chat statements to document what is happening. Just add // at the beginning of the lines for chat if you don't want them to execute.

The light generated is white, set to a radius of 4 meters, with an intensity of .5 and falloff of .75

When the light is on, the prim will glow with an intensity of 0.2.

Here are the variables I used, placed alongside the LSL description. You can change them, if you wish:

PRIM_POINT_LIGHT, integer boolean (TRUE), vector color(<1.0, 1.0, 1.0>, white), float intensity (0.5), float radius (4.0), float falloff (0.75)

PRIM_GLOW, integer face (All Sides), float intensity (0.2)

Touch will cause a click sound to be played; comment that out if you wish to silence it.

Script Follows. Just highlight and cut, paste it into a script in your prim, save, and you're good to go.

//================

integer on = TRUE;
// this is an integer (whole number) that switches between off (FALSE, or 0) and on (TRUE, or 1)
// We start with the integer set to TRUE (on)


default
{
    state_entry()
    {
            //If you want the script to do something whenever it starts, your code goes here
    }
 
    touch_start(integer x)
        // When touch starts
     
     {
        if (on == TRUE)
        {
             // Turn Light On
             llPlaySound("7d5e27f4-9e0d-4f1d-b449-8499d56f5d00", 0.5);
             llSay(0, "The light is on.");
             llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1.0, 1.0, 1.0>, 0.5, 4.0, 0.75, PRIM_GLOW, ALL_SIDES, 0.2]);
             on = FALSE;
     
        }

    else if (on == FALSE)
        {
             // Turn Light Off
             llPlaySound("7d5e27f4-9e0d-4f1d-b449-8499d56f5d00", 0.5);
             llSay(0, "The light is off");
             llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <1.0, 1.0, 1.0>, 0.5, 4.0, 0.75, PRIM_GLOW, ALL_SIDES, 0.0]);
             on = TRUE;
         
        }

    }
}

// ====================

1 comment:

  1. JSMH LIMITED :: Gambling in Ireland - JSMH
    JSMH, Limited 계룡 출장마사지 is a 서울특별 출장마사지 licensed 부산광역 출장샵 betting and gaming company based in Greater London, United 경산 출장안마 Kingdom. JSMH operates in Ireland, 양산 출장샵 Malta and

    ReplyDelete