Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

specific prims

Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
06-16-2008 05:41
I need to change colors of only a few prims(10-12 prims) in a multi-prim object (30-40 prims) with a chat command. I just need suggestions on how to do this.

Thanks
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
06-16-2008 06:08
change the names of all the prims whose color you want to change to something
then iterate through all the prims, use llGetLinkName and change the prim's color if it matches

example! this changes the color of all prims named "spike" when you say something like "color dark red" on channel 0. You can change all that at the top of the script

From: someone
// Day Oh's 140 Color Changer
// for linked prims with a given name
// Note: Not designed for single-prim objects

integer CHANNEL = 0;
string TRIGGER = "color";
string TARGETS = "spike";



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.647059, 0.164706, 0.164706>, <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)
{
integer trigger_length = llStringLength(TRIGGER);
message = llToLower(message);
if(llGetSubString(message, 0, trigger_length) == TRIGGER + " ";)
{
vector color = color_picker(llGetSubString(message, trigger_length + 1, -1));
integer linkend = llGetNumberOfPrims() + 1;
integer i = 1;
do
{
if(llGetLinkName(i) == TARGETS)
{
llSetLinkColor(i, color, ALL_SIDES);
}
} while(++i < linkend);
}
}

changed(integer change)
{
if(change & CHANGED_OWNER)
{
llListenRemove(hListen);
hListen = llListen(CHANNEL, "", llGetOwner(), "";);
}
}
}
_____________________
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
06-16-2008 07:46
LOL, that's one hell of a suggestion Day Oh. How is one to learn? lol
Thanks!