Color Changer

From Second Life Wiki
Revision as of 17:20, 7 July 2009 by Neo Calcutt (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is a color changer script I made. Before you use it you should change the channel it listens on and/or replace the second set of quotes with llGetOwner() so it doesn't interfere with other peoples scripts and vice versa.

<lsl> ////////////////////////////////////////////////////////////////////////////////////////////// // Color Changer Plus v1.0 // // by Neo Calcutt // // Distributed under the Creative Commons Attribution-Share Alike 3.0 United States License.// // I would also prefer that you leave the script full permissions. // // // // DO NOT REMOVE THIS TEXT. If you do I will eventually find out. // // And when I do, I will not be happy. // //If you find this script anywhere not full perms, please IM Neo Calcutt (on the teen grid) // //////////////////////////////////////////////////////////////////////////////////////////////



default {

   state_entry()
   {
       llListen(5,"","",""); // Change the channel so it doesn't interfere with other people's color changers, and you might want to replace the second set of quotes with llGetOwner() unless you want others to be able to change it.
   }
   listen(integer channel, string name,  key id, string message) // The listen event. The reason you have to put the stuff in the parentheses in is because it defines the variables that are written to by the function. i.e. if I say foo on channel 5, the script knows that i said foo and i did it on channel 5. If i said it on channel 6, it wouldn't know, because the llListen is set to only listen on channel 5. 
   {
       if (message == "red")       // The colors, and the text.
       {
           llSetColor(<1,0,0>, ALL_SIDES);  // Color, THEN side. Remember that order.
       }
       else if (message == "orange")
       {
           llSetColor(<1,0.5,0>, ALL_SIDES);
       }
       else if (message == "yellow")
       {
           llSetColor(<1,1,0>, ALL_SIDES);
       }
       else if (message == "lime")
       {
           llSetColor(<0.5,1,0>, ALL_SIDES);
       }
       else if (message == "green")
       {
           llSetColor(<0,1,0>, ALL_SIDES);
       }
       else if (message == "teal")
       {
           llSetColor(<0,1,0.5>, ALL_SIDES);
       }
       else if (message == "cyan")
       {
           llSetColor(<0,1,1>, ALL_SIDES);
       }
       else if (message == "light blue")
       {
           llSetColor(<0,1,0.5>, ALL_SIDES);
       }
       else if (message == "blue")
       {
           llSetColor(<0,0,1>, ALL_SIDES);
       }
       else if (message == "purple")
       {
           llSetColor(<0.5,0,1>, ALL_SIDES);
       }
       else if (message == "magenta")
       {
           llSetColor(<1,0,1>, ALL_SIDES);
       }
       else if (message == "pink")
       {
           llSetColor(<1,0,0.5>, ALL_SIDES);
       }
       else if (message == "white")
       {
           llSetColor(<1,1,1>, ALL_SIDES);
       }
       else if (message == "random")
       {
           float r = llFrand(1);         // Chooses a random color from 0 to 0.999999 and sets it to a variable.
           float g = llFrand(1);
           float b = llFrand(1);
           llSetColor(<r,g,b>, ALL_SIDES);   // Reads our variables and makes it into a color, and sets it.
       }
       else
       {
           llSetColor(message, ALL_SIDES);   // Allows us to enter a float value as our color. If you enter a word that is invalid, it sets the color to black. This is why I didn't enter an else if for black. If you type in black, it is invalid and it sets it to black :P
       }       
   }

} </lsl>