Colour or Color Change With Menu

Expired

// when touched, present a dialog with four color choices
 
integer CHANNEL = 42; // dialog channel
list MENU_MAIN = ["red", "blue", "darkblue", "green", "purple", "white", "black", "teal", "...more colors"]; // the main menu
list MENU_OPTIONS = []; // a submenu
 
default {
        state_entry() 
 
        {
                llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
        }
        touch_start(integer total_number)
        {
                llDialog(llDetectedKey(0), "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click
        }
        listen(integer channel, string name, key id, string message)
        {
                if (llListFindList(MENU_MAIN + MENU_OPTIONS, [message]) != -1)  // verify dialog choice
                {
                        llSay(0, name + " picked the option '" + message + "'."); // output the answer
                        if (message == "...more colors")
                        llDialog(id, "Pick an option!", MENU_OPTIONS, CHANNEL); // present submenu on request
                        else if (message == "...Back")
                        llDialog(id, "What do you want to do?", MENU_MAIN, CHANNEL); // present main menu on request to go back
                        // here you have the name and key of the user and can easily verify if they have the permission to use that option or not
                        else if (message == "red")
                        llSetColor(<255 ,255,255>, ALL_SIDES);
                        else if (message == "white")
                        llSetColor(<255 ,255,255>, ALL_SIDES);
                        else if (message == "black")
                        llSetColor(<0,0,0>, ALL_SIDES);
                        else if (message == "green")
                        llSetColor(<0,125,0>, ALL_SIDES);
                        else if (message == "purple")
                        llSetColor(<127 ,0,127>, ALL_SIDES);
                        else if (message == "blue")
                        llSetColor(<0,0,255>, ALL_SIDES);
                        else if (message == "darkblue")
                        llSetColor(<0,0,127>, ALL_SIDES);
                        else if (message == "teal")
                        llSetColor(<0,127,127>, ALL_SIDES);
                } else
                llSay(0, name + " picked invalid option '" + llToLower(message) + "'."); // not a valid dialog choice
        }
}

 

Random Color Changer

Expired

//  Random Color Changer
//  Created by Water Rogers for IBM/Opensource
 
//  Purpose
//  --------------------------------------------------------------
//  This is a basic example of how you can randomize color
//  It aso shows simple on/off functionality and introduces
//  the llMessageLinked() concept for communicating between
//  multiple objects/scripts of the same link set.
 
//  Requirements
//  --------------------------------------------------------------
//  A single prim is all that is necessary for this example.
 
//  GLOBAL VARIABLES
//  --------------------------------------------------------------
 
float   g_Timer     = 5.0;        //  How fast to change colors (seconds)
integer g_RandomOn  = TRUE;       //  The on/off switch for randomizing
 
//  EVENTS
//  --------------------------------------------------------------
 
default
{
    state_entry()
    {
        //  ------------------------------------------------------
        //  This is the entry-point of the script.  After a script
        //  has been saved or reset, this event will fire off first
        //  ------------------------------------------------------
 
        //  Here we set up a simple timer to fire off once every g_Timer
        //  seconds
        llSetTimerEvent(g_Timer);
    }
 
    touch_start(integer num_detected)
    {
        g_RandomOn = !g_RandomOn;
        if(g_RandomOn) llSetTimerEvent(g_Timer);
        else llSetTimerEvent(0);
    }
 
    timer()
    {
        //  This event is called each g_Timer seconds as declared
        //  previously in the state_entry() event.
 
        //  llSetColor() will change the color of an object taking
        //  vector color and integer face as arguments.  the color
        //  vector is in this form:  where
        //  <0,0,0> = Black and <1 ,1,1> = White.  In between 0 and 1
        //  is the focus of our different color values, which is why
        //  we use llFrand() to generate a random float number between
        //  0 and 1.  ALL_SIDES is a bit-field global to tell the script
        //  that we want all faces of the object colored -- otherwise
        //  we could specify a particular face to color using the
        //  integer representation of the face.
        vector rand_color = ;
        llSetColor(rand_color, ALL_SIDES);
 
        //  We also want to control the color of the beam.  Since
        //  llSetColor() only affects the object the script is contained
        //  in, we need to send a message to the beam object within the
        //  link set.  The best way to do this is to send a message
        //  using llMessageLinked().  This works much like a listen
        //  command, except the object only talks to other objects
        //  that are linked to it, making it much more secure.
        llMessageLinked(LINK_SET, 1, (string)rand_color, NULL_KEY);
    }
}