Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Color Changing Object script help

Satai Diaz
Humble Bounty Hunter
Join date: 9 Aug 2003
Posts: 133
06-23-2005 10:30
I got the following script from the library, it works great! However there's some things I would like to do with it but I cannot find it in the script.

1) I would like to be able to modify the script so instead of changing the color on all linked objects it would just change the color on the primary linked object and leave the others alone.

In a perfect world I would like to find out how to add a menu to it so that different objects in a linked object can have it's individual color changed via the menu but that's not important. Basically I just want to be able to modify the script to have it change the color of the primary linked object and leave the other objects alone. Thank you.

CODE
// Global variables

integer g_listener = FALSE; // Listen Handler
integer randomChannel = 0; // Our random channel
integer place = 0; // Place in the Script
integer exit = FALSE; // Exit param
vector color = <1,1,1>; // Global color param

list colors = ["Orange","Purple","Lime","Pink","Teal","Gray","Blue","Red","Green","White","Yellow","Custom"];

list custom = ["0.8","0.9","1.0","0.5","0.6","0.7","0.2","0.3","0.4","0.0","0.1"];


default
{
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
// Refresh the goods
place = 0;
llListenRemove(g_listener);

// Add a random channel
randomChannel = 10 + (integer)llFrand(100000);
g_listener = llListen(randomChannel,"",llGetOwner(),"");

// Fire up the expiration timer
llSetTimerEvent(720.0);

// Fire up the dialog
llDialog(llGetOwner(),"Select a Color Theme:",colors,randomChannel);
}
}
listen(integer chan, string name, key id, string msg)
{
// When we receive a dialog response...
if(chan == randomChannel) // Redundant, unless you want more chans
{
// This depth is reserved for Configuration Options
if(place == 0)
{
llSetTimerEvent(720.0);
++place;

integer test = llListFindList(colors,(list)msg);
if(test != -1)
{
// If we select "Orange"
if(test == 0)
{
color = <1,0.6,0>;
}

// If we select "Purple"
else if(test == 1)
{
color = <0.6,0,1>;
}

// If we select "Lime"
else if(test == 2)
{
color = <0.6,1,0>;
}

// If we select "Pink"
else if(test == 3)
{
color = <1,0,0.6>;
}

// If we select "Teal"
else if(test == 4)
{
color = <0,1,1>;
}

// If we select "Gray"
else if(test == 5)
{
color = <0.5,0.5,0.5>;
}

// If we select "Blue"
else if(test == 6)
{
color = <0.3,0.3,1>;
}

// If we select "Red"
else if(test == 7)
{
color = <1,0.3,0.3>;
}

// If we select "Green"
else if(test == 8)
{
color = <0.3,1,0.3>;
}

// If we select "White"
else if(test == 9)
{
color = <1,1,1>;
}

// If we select "Yellow"
else if(test == 10)
{
color = <1,1,0>;
}

// If we select "Custom"
else if(test == 11)
{
llDialog(llGetOwner(),"Custom Color Mode Selected! Choose a value for RED (Second Life RGB).",custom,randomChannel);
return;
}

llSetLinkColor(LINK_SET,color,ALL_SIDES);

exit = TRUE;
llSetTimerEvent(0.1);
return;
}
else
llSetTimerEvent(0.1);

}
// This depth is reserved for Custom Colors ONLY!
else if(place == 1)
{
llSetTimerEvent(720.0);
++place;

color.x = (float)msg;
llDialog(llGetOwner(),"Choose a value for GREEN (Second Life RGB).",custom,randomChannel);
}
else if(place == 2)
{
llSetTimerEvent(720.0);
++place;

color.y = (float)msg;
llDialog(llGetOwner(),"Choose a value for BLUE (Second Life RGB).",custom,randomChannel);
}
else if(place == 3)
{
llSetTimerEvent(720.0);
++place;

color.z = (float)msg;

llSetLinkColor(LINK_SET,color,ALL_SIDES);

exit = TRUE;
llSetTimerEvent(0.1);
return;
}
}
}
timer()
{
llSetTimerEvent(0.0);
if(exit == FALSE) llOwnerSay("Timer Expired. Please try again.");
llListenRemove(g_listener);
}
}
_____________________
Satai Diaz
Owner of SD Designs
DJ for Crystal Blue @ Cafe Hailey
Producer of Digital Paradise Studios & Cinema
Admiral of Kazenojin
Owner of SLRA
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
06-23-2005 10:39
change this line:

CODE

llSetLinkColor(LINK_SET,color,ALL_SIDES);


to this:

CODE

llSetColor(color,ALL_SIDES);
Satai Diaz
Humble Bounty Hunter
Join date: 9 Aug 2003
Posts: 133
06-23-2005 12:03
Awesome thanks!

P.S. Any way to get that menu to to do color change on seperate linked objects? hehe

Also I should have asked if there is a way to do color change on multiple linked objects EXCEPT the primary linked.
_____________________
Satai Diaz
Owner of SD Designs
DJ for Crystal Blue @ Cafe Hailey
Producer of Digital Paradise Studios & Cinema
Admiral of Kazenojin
Owner of SLRA
Satai Diaz
Humble Bounty Hunter
Join date: 9 Aug 2003
Posts: 133
06-24-2005 01:57
FYI, if anyone wants to know you can change the color of the children only by changing this:

CODE
llSetLinkColor(LINK_SET,color,ALL_SIDES); 



to this


CODE
llSetLinkColor(LINK_ALL_CHILDREN,color,ALL_SIDES); 
_____________________
Satai Diaz
Owner of SD Designs
DJ for Crystal Blue @ Cafe Hailey
Producer of Digital Paradise Studios & Cinema
Admiral of Kazenojin
Owner of SLRA
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
06-24-2005 03:42
You can use the variations on link set to do it. Where you've used LINK_SET, LINK_CHILDREN etc. you can put an integer that refers to a single member of the linked set.

If you've got three items they have link numbers 1, 2, and 3. (0 for unlinked objects) Doing

llSetLinkColor(1, color, ALL_SIDES);
llSetLinkColour(3, color, ALL_SIDES);

will change the root prim and prim 3, leaving prim 2 alone. You can work out the variations from there I suspect. The intro here and the links might help a bit further.