Since the linked message example in the Wiki isn't very clear, I've put this little tutorial together, in the hope it helps. These aren't necessarily the best ways of changing link prims' colours and so on, but they do help, I think, to demonstrate how link messages work.
Example 1:
Simple script to change colours on touch:
// Example 1
integer toggle = 1;
default
{
touch_start(integer total_number)
{
toggle *= -1;
if (toggle < 0)
{
llWhisper(0, "Turning Red");
llSetColor(<1,0,0>, ALL_SIDES);
}
else if (toggle > 0)
{
llWhisper(0, "Turning Green");
llSetColor(<0,1,1>, ALL_SIDES);
}
}
}
Now, put the following script, receiver1, into as many prims as you like and link them up
//receiver1
integer toggle = 1;
default
{
link_message(integer sender_num, integer num, string str, key id)
{
toggle *= -1;
if (toggle < 0)
{
llWhisper(0, "Turning Red");
llSetColor(<1,0,0>, ALL_SIDES);
}
else if (toggle > 0)
{
llWhisper(0, "Turning Green");
llSetColor(<0,1,1>, ALL_SIDES);
}
}
}
. ..Then put this script, sender1, into another prim.
//sender1
default
{
touch_start(integer total_number)
{
llMessageLinked(LINK_SET, 0, "Touched.", NULL_KEY);
}
}
Touch that prim first, and then link it to the set of prims containing the receiver script (for this example, we don't want it to be the root prim). Then touch the sender prim and, if things have gone according to plan, all the prims with the receiver script in should toggle between red and green.
What's happening is that touching the sender prim is sending a message (which doesn't actually say anything) to the rest of the linkset (that's what LINK_SET is for). The receiver script receives the message and, in effect, says, "oh.. I've received a message.. when that happens I change the value of toggle.".
In effect, it's made the touch communicate itself to the other prims containing the receiver script.
Example 2
Put this, example2, into a prim, and name the prim something. Touch it, and it should say something to you.
//example2
key avi;
key mykey;
default
{
touch_start(integer total_number)
{
avi = llDetectedKey(0);
mykey = llGetKey();
llSay(0, llKey2Name (avi) + " touched me, and I am " + llKey2Name(mykey));
}
}
Then put receiver2
//receiver2
default
{
link_message(integer sender_num, integer num, string avi, key sender)
{
llSay(0, avi + " touched " + llKey2Name(sender));
}
}
and sender2 into two separate prims, give the prim containing sender2 a different name from that of the one containing receiver2, and link the two up.
//sender2
key avi;
key mykey;
default
{
touch_start(integer total_number)
{
avi = llDetectedKey(0);
mykey = llGetKey();
llMessageLinked(LINK_SET, 0, llKey2Name (avi), mykey);
}
}
Again, make sure the sender isn't the root prim (there's nothing wrong with having the sender in the root prim -- often you will want to -- but for the purposes of these examples, I think having it in a child prim makes it easier to see what's happening).
In this example, the link message has not only told the receiver that someone's touched the sender but also given the receiver some data to use and process.
Hope this is of some use.