Difference between revisions of "Color Changer"
Jump to navigation
Jump to search
Neo Calcutt (talk | contribs) |
m (<lsl> tag to <source>) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{LSL Header}} | {{LSL Header}} | ||
<source lang="lsl2"> | |||
// 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 | default | ||
Line 21: | Line 15: | ||
state_entry() | state_entry() | ||
{ | { | ||
llListen( | llListen(listenChannel, "", NULL_KEY, ""); | ||
} | } | ||
listen(integer channel, string name, key id, string message) | |||
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 | |||
else if (message == " | // if (llGetOwnerKey(id) != llGetOwner()) return; | ||
// this would be black | |||
vector color = ZERO_VECTOR; | |||
else if (message == " | |||
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 == " | 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 == "green") | 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 == " | 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 == " | else if (message == "gray") color = <0.667, 0.667, 0.667>; | ||
else if (message == " | |||
else if (message == " | |||
else if (message == "purple") | |||
else if (message == " | |||
else if (message == " | |||
else if (message == " | |||
else if (message == "random") | else if (message == "random") | ||
{ | { | ||
float r = llFrand(1); | float r = llFrand(1.0); | ||
float g = llFrand(1); | float g = llFrand(1.0); | ||
float b = llFrand(1); | float b = llFrand(1.0); | ||
color = <r, g, b>; | |||
} | } | ||
else | else if (llSubStringIndex(message, "<") == 0) | ||
color = (vector)message; | |||
llSetColor(color, ALL_SIDES); | |||
} | } | ||
} | } | ||
</ | </source> |
Latest revision as of 18:38, 24 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
// 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);
}
}