Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Linked Prim color help

Ranya Palmer
*Smoking Ace*
Join date: 21 Apr 2007
Posts: 46
12-09-2008 00:11
is it possible to use one script to change the color of certain prims linked to
one object?

like for example: lets say i want prim A(root prim) to hold a changing
color script but i dont want prim A to change color, i want to be able to
change the color of prim B and C which will both have the name "color"

is there a way for me to get this script to only change the color of any
prim with a name(like "color" for example) that is linked to the root prim?



integer lHandle = -1;
integer run = 1;



vector Color = <0,1,1>;


vector string2vector(string s)
{
list foo = llCSV2List(s);
vector v;
v.x = llList2Float(foo,0);
v.y = llList2Float(foo,1);
v.z = llList2Float(foo,2);
return v;
}

float fixColor(integer c)
{
if (c > 255) return 255;
if (c <= 0) return 0;
return (float)c/255;
}

vector colorVector(string s)
{
list foo = llCSV2List(s);
vector v;
v.x = fixColor(llList2Integer(foo,0));
v.y = fixColor(llList2Integer(foo,1));
v.z = fixColor(llList2Integer(foo,2));
//llWhisper(0, "Debug: v: " + (string)v);
return v;
}



default
{
state_entry()
{
llListenRemove(0);
if (lHandle == -1) lHandle = llListen(0, "", llGetOwner(), "";);

}
on_rez(integer peram)
{
llResetScript();
}
listen(integer channel, string name, key id, string msg)
{
list argv = llParseString2List(msg, [" "], []);
integer argc = llGetListLength(argv);
string cmd = llToLower(llList2String(argv, 0));
//this is where you can change the command to any thing else //(like the parts name for example)
if (cmd == "gripcolor" | cmd == "guncolor";)
{
Color = colorVector(llList2String(argv, 1));
llSetColor((Color), ALL_SIDES);
}

}
}



thanks in advance.
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
12-09-2008 02:41
Use llSetLinkColor(linknumber,colorvector,sides); I recommend checking out the wiki's. You'll find answers like this really easy. If you had looked up llSetColor you would've seen a reference to llSetLinkColor. :)
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
12-09-2008 02:43
You can use the function "llSetLinkColor" to set the colour of a specific other link in the set. You can also use "llSetLinkPrimitiveParams".

And by the way, you can usually just cast between strings and vectors, like this:

string str = "<1.0, 2.0, 3.0>";
vector vec = (vector)str;



EDIT: doh! Was beaten to it...