Difference between revisions of "Color Changer"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '{{LSL Header}} 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 i...')
 
m (<lsl> tag to <source>)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}
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.
<source lang="lsl2">
 
// Color Changer Plus v1.0
<lsl>
// by Neo Calcutt
//////////////////////////////////////////////////////////////////////////////////////////////
//
//                                    Color Changer Plus v1.0                               //
// distributed under the Creative Commons Attribution-Share Alike 3.0 United States License.
//                                       by Neo Calcutt                                   //
//
// Distributed under the Creative Commons Attribution-Share Alike 3.0 United States License.//
// please leave the script full permissions and keep this header intact
//               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) //
//////////////////////////////////////////////////////////////////////////////////////////////
 
 


//  you might want to change this
integer listenChannel = 5;


default
default
Line 21: Line 15:
     state_entry()
     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.
         llListen(listenChannel, "", NULL_KEY, "");
     }
     }
     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.
 
     listen(integer channel, string name,  key id, string message)
     {
     {
        if (message == "red")       // The colors, and the text.
    //  uncomment the next line to only listen to the owner
         {
    //  if (id != llGetOwner()) return;
            llSetColor(<1,0,0>, ALL_SIDES); // Color, THEN side. Remember that order.
 
        }
    // uncomment the next line to only listen to the owner and other objects by the owner
         else if (message == "orange")
    //  if (llGetOwnerKey(id) != llGetOwner()) return;
        {
 
            llSetColor(<1,0.5,0>, ALL_SIDES);
    //  this would be black
        }
         vector color = ZERO_VECTOR;
         else if (message == "yellow")
 
         {
        if (message == "navy")        color = <0.000, 0.122, 0.247>;
            llSetColor(<1,1,0>, ALL_SIDES);
         else if (message == "blue")   color = <0.000, 0.455, 0.851>;
        }
         else if (message == "aqua")   color = <0.498, 0.859, 1.000>;
         else if (message == "lime")
         else if (message == "teal")    color = <0.224, 0.800, 0.800>;
        {
         else if (message == "olive")   color = <0.239, 0.600, 0.439>;
            llSetColor(<0.5,1,0>, ALL_SIDES);
         else if (message == "green")   color = <0.180, 0.800, 0.251>;
        }
         else if (message == "lime")   color = <0.004, 1.000, 0.439>;
         else if (message == "green")
         else if (message == "yellow") color = <1.000, 0.863, 0.000>;
        {
         else if (message == "orange")  color = <1.000, 0.522, 0.106>;
            llSetColor(<0,1,0>, ALL_SIDES);
         else if (message == "red")     color = <1.000, 0.255, 0.212>;
        }
         else if (message == "maroon")  color = <0.522, 0.078, 0.294>;
         else if (message == "teal")
         else if (message == "fuchsia") color = <0.941, 0.071, 0.745>;
        {
         else if (message == "purple") color = <0.694, 0.051, 0.788>;
            llSetColor(<0,1,0.5>, ALL_SIDES);
         else if (message == "white")   color = <1.000, 1.000, 1.000>;
        }
         else if (message == "silver") color = <0.867, 0.867, 0.867>;
         else if (message == "cyan")
         else if (message == "gray")   color = <0.667, 0.667, 0.667>;
         {
            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")
         else if (message == "random")
         {
         {
             float r = llFrand(1);         // Chooses a random color from 0 to 0.999999 and sets it to a variable.
             float r = llFrand(1.0);
             float g = llFrand(1);
             float g = llFrand(1.0);
             float b = llFrand(1);
             float b = llFrand(1.0);
             llSetColor(<r,g,b>, ALL_SIDES);   // Reads our variables and makes it into a color, and sets it.
             color = <r, g, b>;
         }
         }
         else
         else if (llSubStringIndex(message, "<") == 0)
         {
            color = (vector)message;
            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
 
        }     
         llSetColor(color, ALL_SIDES);
     }
     }
}
}
</lsl>
</source>

Latest revision as of 18:38, 24 January 2015

//  Color Changer Plus v1.0
//  by Neo Calcutt
//
//  distributed under the Creative Commons Attribution-Share Alike 3.0 United States License.
//
//  please leave the script full permissions and keep this header intact

//  you might want to change this
integer listenChannel = 5;

default
{
    state_entry()
    {
        llListen(listenChannel, "", NULL_KEY, "");
    }

    listen(integer channel, string name,  key id, string message)
    {
    //  uncomment the next line to only listen to the owner
    //  if (id != llGetOwner()) return;

    //  uncomment the next line to only listen to the owner and other objects by the owner
    //  if (llGetOwnerKey(id) != llGetOwner()) return;

    //  this would be black
        vector color = ZERO_VECTOR;

        if (message == "navy")         color = <0.000, 0.122, 0.247>;
        else if (message == "blue")    color = <0.000, 0.455, 0.851>;
        else if (message == "aqua")    color = <0.498, 0.859, 1.000>;
        else if (message == "teal")    color = <0.224, 0.800, 0.800>;
        else if (message == "olive")   color = <0.239, 0.600, 0.439>;
        else if (message == "green")   color = <0.180, 0.800, 0.251>;
        else if (message == "lime")    color = <0.004, 1.000, 0.439>;
        else if (message == "yellow")  color = <1.000, 0.863, 0.000>;
        else if (message == "orange")  color = <1.000, 0.522, 0.106>;
        else if (message == "red")     color = <1.000, 0.255, 0.212>;
        else if (message == "maroon")  color = <0.522, 0.078, 0.294>;
        else if (message == "fuchsia") color = <0.941, 0.071, 0.745>;
        else if (message == "purple")  color = <0.694, 0.051, 0.788>;
        else if (message == "white")   color = <1.000, 1.000, 1.000>;
        else if (message == "silver")  color = <0.867, 0.867, 0.867>;
        else if (message == "gray")    color = <0.667, 0.667, 0.667>;
        else if (message == "random")
        {
            float r = llFrand(1.0);
            float g = llFrand(1.0);
            float b = llFrand(1.0);
            color = <r, g, b>;
        }
        else if (llSubStringIndex(message, "<") == 0)
            color = (vector)message;

        llSetColor(color, ALL_SIDES);
    }
}