Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

color changing objects

Mickeylicious Munster
Registered User
Join date: 20 Feb 2008
Posts: 49
02-11-2009 00:47
if there is 17 prim linked couch and you put a menu driven color changing script in the linked parts you want to be able to change the color of but it changes the entire couch including some parts not wanted to be color changed how do you fix this?
Arcane Clawtooth
5 By 5
Join date: 7 Jan 2008
Posts: 201
02-11-2009 01:00
From: Mickeylicious Munster
if there is 17 prim linked couch and you put a menu driven color changing script in the linked parts you want to be able to change the color of but it changes the entire couch including some parts not wanted to be color changed how do you fix this?

Simple, use the llSetLinkColor() function to only change the colors of the prims you want to change. You could name those prims a common name and collect their link numbers in a list at rez time.

Did that help?

BTW, this really belongs in the scripting forum.
_____________________
Visit Clawtooth Creations for all (well, a few) of your decorating needs.

Hey, check out the occasional picture in my flickr page. http://flickr.com/photos/30584092@N03/

Ok, I really need to finish something someday *sigh*
Mickeylicious Munster
Registered User
Join date: 20 Feb 2008
Posts: 49
no
02-11-2009 01:49
i am confused i named the prims ands i opened the script and found where it says set link color but where do i put the object name at? or dont i ?
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
02-11-2009 11:18
llSetLinkColor(integer linknumber, vector color, integer face)

It's a link number thing not an object/prim name thing.

If linknumber is set to LINK_SET this applies to all prims in the object. The alternative is to specify the individual link number, unfortunately this means you will need many llSetLinkColor statements to set the colour of a subset of the prims in an object's linkset.

Also, it's not easy to determine the link number of a prim without using a script ...hence Arcane suggested forming a list of the link numbers based on a common prim name when rezzing the object (not a trivial task).

BTW, this really belongs in the scripting forum. :)
_____________________
Arcane Clawtooth
5 By 5
Join date: 7 Jan 2008
Posts: 201
02-12-2009 02:02
Untested bit of code that should point you in the right direction. For any further help, please post in the scripting forum.

CODE

string codeword = "tint";

list tintable = [];

changeColor(vector color)
{
integer tot = llGetListLength(tintable);
integer i = 0;
for(i = 0; i < tot; i++)
{
llSetLinkColor(i, color, ALL_SIDES);
}
}

init()
{
integer tot = llGetNumberOfPrims();
integer i = 0;
for(i = 0; i < tot; i++)
{
if(llGetLinkName(i) == codeword)
{
tintable += i;
}
}
}

default
{
state_entry()
{
init();
}
}
_____________________
Visit Clawtooth Creations for all (well, a few) of your decorating needs.

Hey, check out the occasional picture in my flickr page. http://flickr.com/photos/30584092@N03/

Ok, I really need to finish something someday *sigh*
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
02-12-2009 07:08
Like most programming tasks, there is more than one valid approach.

Doing the color changes by link number is the most efficient, as there is only the one script involved, in the root prim. But if you (or a later customer) add or remove prims, the link numbers of the prims change. So if someone de-links a trhow pillow, maybe now one of the wooden legs of the couch will unexpectedly color change, while some cushion does not.

You can also do this with llMessageLinked, placing a control script in the root prim and listener scripts using the link_message state in the specific prims that need to respond.

As an example, you have a couch with upholstery, wood legs, and metal trim. The legs will never color change. The upholstery changes texture and possibly color depending on messages sent from the control script, while the metal detects the same change commands and interprets them to change color so the metal shifts from silver to gold.

The down side of this is, of course, that you have a LOT more scripts active. Every changing prim has a script, and the root may have both types, if it is visible. But you also have complete control, no matter what gets linked or de-linked, added or removed. As long as the root prim remains the root, and the scripts are not removed, all the linked parts will respond as expected, as long as they are part of that linkset.

Depending on how you activate the control script, you might have one open listen, to accept typed control commands, or it may be touch-activated to be controlled by a menu, or both. But the "listening" prims don't have open chat listeners. They only respond to mesages from the root prim.

Ask in Scripting Tips for more detailed responses.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.