Difference between revisions of "Color Changer"
Jump to navigation
Jump to search
Neo Calcutt (talk | contribs) |
Kireji Haiku (talk | contribs) m (some readability improvements) |
||
Line 1: | Line 1: | ||
{{LSL Header}} | {{LSL Header}} | ||
This is a color changer script I made | This is a color changer script I made. | ||
<lsl> | <lsl> | ||
// | // 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 17: | ||
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 == "orange") | // if (llGetOwnerKey(id) != llGetOwner()) return; | ||
// this would be black | |||
vector color = ZERO_VECTOR; | |||
else if (message == "yellow") | |||
if (message == "red") color = <1.0, 0.0, 0.0>; | |||
else if (message == "orange") color = <1.0, 0.5, 0.0>; | |||
else if (message == "yellow") color = <1.0, 1.0, 0.0>; | |||
else if (message == "lime") | else if (message == "lime") color = <0.5, 1.0, 0.0>; | ||
else if (message == "green") color = <0.0, 1.0, 0.0>; | |||
else if (message == "teal") color = <0.0, 1.0, 0.5>; | |||
else if (message == "cyan") color = <0.0, 1.0, 1.0>; | |||
else if (message == "green") | else if (message == "light blue") color = <0.0, 0.5, 1.0>; | ||
else if (message == "blue") color = <0.0, 0.0, 1.0>; | |||
else if (message == "purple") color = <0.5, 0.0, 1.0>; | |||
else if (message == "magenta") color = <1.0, 0.0, 1.0>; | |||
else if (message == "teal") | else if (message == "pink") color = <1.0, 0.0,0.5>; | ||
else if (message == "white") color = <1.0, 1.0, 1.0>; | |||
else if (message == "cyan") | |||
else if (message == "light blue") | |||
else if (message == "blue") | |||
else if (message == "purple") | |||
else if (message == "magenta") | |||
else if (message == "pink") | |||
else if (message == "white") | |||
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); | |||
} | } | ||
} | } | ||
</lsl> | </lsl> |
Revision as of 01:24, 21 October 2012
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
This is a color changer script I made.
<lsl> // 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 == "red") color = <1.0, 0.0, 0.0>; else if (message == "orange") color = <1.0, 0.5, 0.0>; else if (message == "yellow") color = <1.0, 1.0, 0.0>; else if (message == "lime") color = <0.5, 1.0, 0.0>; else if (message == "green") color = <0.0, 1.0, 0.0>; else if (message == "teal") color = <0.0, 1.0, 0.5>; else if (message == "cyan") color = <0.0, 1.0, 1.0>; else if (message == "light blue") color = <0.0, 0.5, 1.0>; else if (message == "blue") color = <0.0, 0.0, 1.0>; else if (message == "purple") color = <0.5, 0.0, 1.0>; else if (message == "magenta") color = <1.0, 0.0, 1.0>; else if (message == "pink") color = <1.0, 0.0,0.5>; else if (message == "white") color = <1.0, 1.0, 1.0>; 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); }
} </lsl>