Menu Driven Texture Selector

Written by: Headmaster

Foun in the Second Life Scripting Library Forum:

integer HANDLE;
integer CHANNEL = -44567;
float INTENSITY = 10.0;
float RADIUS = 6.0;
float FALLOFF = .25;
integer FACE = 5;

list COLOR_LIST = ["white", "red", "green",
                   "blue", "yellow", "orange",
                   "purple", "pink", "cyan", "off", "random"];
list COLOR_VALUE = [<1, 1, 1>, <1, .0, .0>, <0, 1, 0>,
                    <0, 0, 1>, <1, 1, 0>, <1, .05, .0>,
                    <1, 0, 1>, <1, .02, .02>, <0, 1, 1>]; 

pColor(vector color)
{
   llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, color, INTENSITY, RADIUS, FALLOFF,
                         PRIM_COLOR, FACE, color, llGetAlpha(FACE),
                         PRIM_GLOW, FACE, 1.0]);
}

default
{
    touch_start(integer total_number)
    {
        HANDLE = llListen(CHANNEL, "", NULL_KEY, "");
        llDialog(llDetectedKey(0), "Color?", COLOR_LIST, CHANNEL);
    }

    listen(integer channel, string name, key id, string message)
    {
       llListenRemove(HANDLE);

       if(message == "off")
       {
           llSetTimerEvent(0.0);
           llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0, 0, 0>, 0, 0, 0,
                                 PRIM_COLOR, FACE, <.95, .95, .95>, llGetAlpha(FACE),
                                 PRIM_GLOW, FACE, 0.0]);
           llWhisper(0,"Lights out");
       }
       else if(message == "random") llSetTimerEvent(1.0);
       else
       {
           llSetTimerEvent(0.0);
           integer i = llListFindList(COLOR_LIST, [message]);
           vector color = llList2Vector(COLOR_VALUE, i);
           pColor(color);
       }
    }

    timer()
    {
        vector color = llList2Vector(COLOR_VALUE, (integer)(llFrand(llGetListLength(COLOR_VALUE))));
        pColor(color);
    }
}