color_timer()

color-timer.lsl
// cycle through a list of colors
 
integer SPOT_CHANNEL  = 1520;   
 
// How long to show each color (seconds)
float delay = 3.0;
 
// Define the color vectors
vector Blue = <0.2, 0.2, 0.4>;      // Blue
vector Cyan = <0.0, 0.314, 0.314>;  // Cyan
vector Green = <0.0, 0.5, 0.0>;     // Green
vector Gold = <0.5, 0.25, 0.0>;     // Gold
 
// Show the colors in this order
list colors = [Blue, Cyan, Green, Gold];
 
integer index = 0;
 
default {
    state_entry() {
        llListen(SPOT_CHANNEL, "", "", "");       // Listen for HUD Commands
        llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, ALL_SIDES, 1, 1, 1.0, 1, 0.05);
        llSetTimerEvent(delay);
    }
 
    timer() {
        llSetColor(llList2Vector(colors, index), ALL_SIDES );  //change the face's color
        llSetLinkPrimitiveParamsFast(LINK_THIS, [
            PRIM_GLOW, ALL_SIDES, 0.07,
            PRIM_POINT_LIGHT, TRUE, llList2Vector(colors, index), 1.0, 10.0, 0.6
        ]);
        index += 1;
        if (index == llGetListLength(colors)) {
            index = 0;
        }
    }
 
    listen(integer channel, string name, key id, string message) {
        if (message == "ON") {
            llSetAlpha(0.2, ALL_SIDES);
            llSetPrimitiveParams([
                PRIM_GLOW, ALL_SIDES, 0.07,
                PRIM_POINT_LIGHT, TRUE, <1,1,1>, 1.0, 10.0, 0.6
            ]);
        }
        else if (message == "OFF") {
            llSetAlpha(0, ALL_SIDES);
            llSetPrimitiveParams([
                PRIM_GLOW, ALL_SIDES, 0,
                PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 1.0, 10.0, 0.6
            ]);
        }
    }
}