Day Oh's 140 Color Changer Script

No promotion here please! Discuss building, collecting, and using community catchables and 7Seas-compatible buyables. Any registered user can start new threads here and reply.

Day Oh's 140 Color Changer Script

Postby Jen Shikami » 26 Mar 2009, 06:14

A few people have asked for a color changer script, so here's the freebie version we used as a basis for the color changing in our fishing rods.

I am not a coder and from what I hear this freebie version doesn't use a very efficient method, since you need a copy inside every individual prim that you want to change... but hey, it works, and it's free. Might as well share!

If you want some images to use as a visual key to all these color names, use the graphics from the end of the fishing rod manual. The color names are all spelled out there, too.

To have different pieces change color separately, make a duplicate of the script that's modified to use a different listen channel.

If it helps, when I explain this to customers in my item's manual, I describe usage as follows:

Fill in the blank with one of the color choices listed at the bottom of the notecard:
To change fin color, type: /8880 color ____
To change body color, type: /8881 color ____

(and of course I change the scripts I use to listen to either channel 8880 or 8881...)

Script itself follows:
Last edited by Jen Shikami on 26 Mar 2009, 06:15, edited 1 time in total.
Official builder for 7Seas Fishing. Learn more at http://7seasfishing.com
For technical support, please contact 7Seas Sass by IM in Second Life.
User avatar
Jen Shikami
 
Posts: 36
Joined: 18 Dec 2008, 10:35

Re: Day Oh's Color Changer Script

Postby Jen Shikami » 26 Mar 2009, 06:14

// Day Oh's 140 Color Changer
// for Prim

integer CHANNEL = 7471; // change this channel if you want to have different parts of your object be different colors... so you could make the fish's fins listen for one channel and the body listen for another, for example.



list color_names;
list color_vectors;

integer hListen;



color_setup()
{
color_names = ["aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "green", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow"] + ["lightgreen"] + ["lightgrey", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue"] + ["lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumauqamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow"] + ["yellowgreen"];
color_vectors = [<0.941176, 0.972549, 1.000000>, <0.980392, 0.921569, 0.843137>, <0.000000, 1.000000, 1.000000>, <0.498039, 1.000000, 0.831373>, <0.941176, 1.000000, 1.000000>, <0.960784, 0.960784, 0.862745>, <1.000000, 0.894118, 0.768627>, <0.000000, 0.000000, 0.000000>, <1.000000, 0.921569, 0.803922>, <0.000000, 0.000000, 1.000000>, <0.541176, 0.168627, 0.886275>, <0.247059, 0.104706, 0.104706>, <0.870588, 0.721569, 0.529412>, <0.372549, 0.619608, 0.627451>, <0.498039, 1.000000, 0.000000>, <0.823529, 0.411765, 0.117647>, <1.000000, 0.498039, 0.313726>, <0.392157, 0.584314, 0.929412>, <1.000000, 0.972549, 0.862745>, <0.862745, 0.078431, 0.235294>, <0.000000, 1.000000, 1.000000>, <0.000000, 0.000000, 0.545098>, <0.000000, 0.545098, 0.545098>, <0.721569, 0.525490, 0.043137>, <0.662745, 0.662745, 0.662745>, <0.000000, 0.392157, 0.000000>, <0.741176, 0.717647, 0.419608>, <0.545098, 0.000000, 0.545098>, <0.333333, 0.419608, 0.184314>, <1.000000, 0.549020, 0.000000>, <0.600000, 0.196078, 0.800000>, <0.545098, 0.000000, 0.000000>, <0.913725, 0.588235, 0.478431>, <0.560784, 0.737255, 0.560784>, <0.282353, 0.239216, 0.545098>, <0.184314, 0.309804, 0.309804>, <0.000000, 0.807843, 0.819608>, <0.580392, 0.000000, 0.827451>, <1.000000, 0.078431, 0.576471>, <0.000000, 0.749020, 1.000000>, <0.411765, 0.411765, 0.411765>, <0.117647, 0.564706, 1.000000>, <0.698039, 0.133333, 0.133333>, <1.000000, 0.980392, 0.941176>, <0.133333, 0.545098, 0.133333>, <1.000000, 0.000000, 1.000000>, <0.862745, 0.862745, 0.862745>, <0.972549, 0.972549, 1.000000>, <1.000000, 0.843137, 0.000000>, <0.854902, 0.647059, 0.125490>, <0.501961, 0.501961, 0.501961>, <0.000000, 0.501961, 0.000000>, <0.678431, 1.000000, 0.184314>, <0.941176, 1.000000, 0.941176>, <1.000000, 0.411765, 0.705882>, <0.803922, 0.360784, 0.360784>, <0.294118, 0.000000, 0.509804>, <1.000000, 1.000000, 0.941176>, <0.941176, 0.901961, 0.549020>, <0.901961, 0.901961, 0.980392>, <1.000000, 0.941176, 0.960784>, <0.486275, 0.988235, 0.000000>, <1.000000, 0.980392, 0.803922>] + [<0.678431, 0.847059, 0.901961>] + [<0.941176, 0.501961, 0.501961>] + [<0.878431, 1.000000, 1.000000>, <0.980392, 0.980392, 0.823529>, <0.564706, 0.933333, 0.564706>, <0.827451, 0.827451, 0.827451>] + [<1.000000, 0.713726, 0.756863>, <1.000000, 0.627451, 0.478431>, <0.125490, 0.698039, 0.666667>, <0.529412, 0.807843, 0.980392>, <0.466667, 0.533333, 0.600000>, <0.690196, 0.768627, 0.870588>, <1.000000, 1.000000, 0.878431>, <0.000000, 1.000000, 0.000000>, <0.196078, 0.803922, 0.196078>, <0.980392, 0.941176, 0.901961>, <1.000000, 0.000000, 1.000000>, <0.501961, 0.000000, 0.000000>, <0.400000, 0.803922, 0.666667>, <0.000000, 0.000000, 0.803922>, <0.729412, 0.333333, 0.827451>, <0.576471, 0.439216, 0.847059>, <0.235294, 0.701961, 0.443137>, <0.482353, 0.407843, 0.933333>, <0.000000, 0.980392, 0.603922>, <0.282353, 0.819608, 0.800000>, <0.780392, 0.082353, 0.521569>, <0.098039, 0.098039, 0.439216>, <0.960784, 1.000000, 0.980392>, <1.000000, 0.894118, 0.882353>, <1.000000, 0.894118, 0.709804>, <1.000000, 0.870588, 0.678431>, <0.000000, 0.000000, 0.501961>, <0.992157, 0.960784, 0.901961>, <0.501961, 0.501961, 0.000000>, <0.407843, 0.556863, 0.137255>, <1.000000, 0.647059, 0.000000>, <1.000000, 0.270588, 0.000000>, <0.854902, 0.439216, 0.839216>, <0.933333, 0.909804, 0.666667>, <0.596078, 0.984314, 0.596078>, <0.686275, 0.933333, 0.933333>, <0.847059, 0.439216, 0.576471>, <1.000000, 0.937255, 0.835294>, <1.000000, 0.854902, 0.725490>, <0.803922, 0.521569, 0.247059>, <1.000000, 0.752941, 0.796078>, <0.866667, 0.627451, 0.866667>, <0.690196, 0.878431, 0.901961>, <0.501961, 0.000000, 0.501961>, <1.000000, 0.000000, 0.000000>, <0.737255, 0.560784, 0.560784>, <0.254902, 0.411765, 0.882353>, <0.545098, 0.270588, 0.074510>, <0.980392, 0.501961, 0.447059>, <0.956863, 0.643137, 0.376471>, <0.180392, 0.545098, 0.341176>, <1.000000, 0.960784, 0.933333>, <0.627451, 0.321569, 0.176471>, <0.752941, 0.752941, 0.752941>, <0.529412, 0.807843, 0.921569>, <0.415686, 0.352941, 0.803922>, <0.439216, 0.501961, 0.564706>, <1.000000, 0.980392, 0.980392>, <0.000000, 1.000000, 0.498039>, <0.274510, 0.509804, 0.705882>, <0.823529, 0.705882, 0.549020>, <0.000000, 0.501961, 0.501961>] + [<0.847059, 0.749020, 0.847059>] + [<1.000000, 0.388235, 0.278431>] + [<0.250980, 0.878431, 0.815686>, <0.933333, 0.509804, 0.933333>, <0.960784, 0.870588, 0.701961>, <1.000000, 1.000000, 1.000000>, <0.960784, 0.960784, 0.960784>] + [<1.000000, 1.000000, 0.000000>, <0.603922, 0.803922, 0.196078>];
}

vector color_picker(string color)
{
color = llStringTrim(llToLower(color), STRING_TRIM);
integer index;
while((index = llSubStringIndex(color, " ")) != -1)
{
color = llGetSubString(color, 0, index - 1) + llGetSubString(color, index + 1, -1);
}

index = llListFindList(color_names, [color]);
if(index != -1)
{
return llList2Vector(color_vectors, index);
}
else
{
return <1.0, 1.0, 1.0>;
}
}



default
{
state_entry()
{
color_setup();
hListen = llListen(CHANNEL, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string message)
{
message = llToLower(message);
if(llGetSubString(message, 0, 5) == "color ")
{
llSetColor(color_picker(llGetSubString(message, 6, -1)), ALL_SIDES);
}
}

changed(integer change)
{
if(change & CHANGED_OWNER)
{
llListenRemove(hListen);
hListen = llListen(CHANNEL, "", llGetOwner(), "");
}
}
}
Official builder for 7Seas Fishing. Learn more at http://7seasfishing.com
For technical support, please contact 7Seas Sass by IM in Second Life.
User avatar
Jen Shikami
 
Posts: 36
Joined: 18 Dec 2008, 10:35


Return to OpenSeas Creations

Who is online

Users browsing this forum: No registered users and 1 guest

cron