Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Grrr... simple controller and listener for color change, but doesn't work

Paulo Dielli
Symfurny Furniture
Join date: 19 Jan 2007
Posts: 780
05-28-2008 20:44
I'm trying to modify a texture change script with a controller and listener into a color change script, also with controller and listener, so I can put the listener in the prims (of a linked set) that need to be changed.

But I can't get it to work. I've changed color values to vector values, but when I touch the prim it turns to black. What do I do wrong?

CONTROLLER:

CODE

list ColorNames = ["White", "Gray"];

list ColorKeys = ["<1,1,1>", "<.5,.5,.5>"];

integer menu_handler;
integer menu_channel;

string ON;
key Dkey;

default
{
touch_start(integer t)
{
Dkey = llDetectedKey(0);
ON = llGetObjectName();
menu_channel = (integer)(llFrand(99999.0) * -1);
menu_handler = llListen(menu_channel,"",Dkey,"");
llDialog(Dkey,ON + " Color Selection Options:", ColorNames, menu_channel);
llSetTimerEvent(15.0);
}
timer()
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
}
listen(integer chan, string name, key id,string msg)
{
if (chan == menu_channel)
{


llMessageLinked(LINK_SET, -9775, "", llList2Key(ColorKeys, llListFindList(ColorNames, (list)msg)));


llDialog(Dkey,ON + "Color Selection Options:", ColorNames, menu_channel);
llSetTimerEvent(15.0);
}
}
}


LISTENER:

CODE

default
{
link_message(integer snum, integer num, string str, key id)
{
if(num == -9775)
{
llSetColor( (vector)str, ALL_SIDES );
}
}
}
Galena Qi
Registered User
Join date: 9 Sep 2006
Posts: 249
05-28-2008 22:22
Unless it is too late at night and I'm seeing cross-eyed, you are passing a key holding the color information in your llMessageLinked statement, but listening for a string in your Listener. Since the listener is never getting values, it is filling in <0,0,0>, which is black.
Georg Stonewall
Husband of Nikki
Join date: 21 Jan 2007
Posts: 211
05-28-2008 22:47
Why don't you use llSetLinkColor?

I know this is not a reply to your question, it's another question, but maybe it helps :-)
_____________________
G&N Quality Design


SLURL

Blog

Flickr

XStreetSL
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
05-28-2008 23:35
You can't pass a key via llLinkedMessage()...

Thus: llMessageLinked(LINK_SET, -9775, "", llList2String(ColorKeys, llListFindList(ColorNames, (list)msg)));

The typecast in the listener-event should work fine, though...
Kronos Avro
Under Construction!
Join date: 15 Dec 2007
Posts: 25
05-29-2008 01:11
Here is one method I use..

Sample:

if (llGetLinkNumber() == 1) llSetLinkColor(LINK_SET, color_vector, ALL_SIDES);
_____________________
Galena Qi
Registered User
Join date: 9 Sep 2006
Posts: 249
05-29-2008 08:31
Haruki:

I guess I'm confused about the syntax and operation of llMessageLinked. The order of values sent is (integer linknum, integer num, string str, key id).


llMessageLinked(LINK_SET, -9775, "", llList2String(ColorKeys, llListFindList(ColorNames, (list)msg))); produces a string value in the key position. The string position is sending "". The listener is set up to receive a string in the string position. Does the order of the values sent not matter?
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
05-29-2008 09:17
From: Haruki Watanabe
You can't pass a key via llLinkedMessage()...

No but with llMessageLinked() it works just fine, I do it all the time
_____________________
From Studio Dora
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
05-29-2008 15:52
From: Galena Qi
Haruki:

I guess I'm confused about the syntax and operation of llMessageLinked. The order of values sent is (integer linknum, integer num, string str, key id).


llMessageLinked(LINK_SET, -9775, "", llList2String(ColorKeys, llListFindList(ColorNames, (list)msg))); produces a string value in the key position. The string position is sending "". The listener is set up to receive a string in the string position. Does the order of the values sent not matter?


llMessageLinked(LINK_SET, -9775, "", llList2Key(ColorKeys, llListFindList(ColorNames, [msg])));
Galena Qi
Registered User
Join date: 9 Sep 2006
Posts: 249
05-29-2008 21:56
I was right the first time. To fix the script, replace the two lines as follows:

list ColorKeys = ["<1,1,1>", "<.5,.5,.5>"];


llMessageLinked(LINK_SET, -9775, llList2String(ColorKeys, llListFindList(ColorNames, [msg])), NULL_KEY);

Now it works.