Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

trying to send a linkmessage

RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
08-24-2004 12:52
I'm trying to send a message to linked objects to change textures. Right now they all listen. (i hear thats bad) So I'm trying to set it so you touch the main one and then it starts listenening and you tell it something it tells all the linked objects to change textures.

but I can't figure out what the syntacs for that would be.
I went to wiki copied the examples of linked message
put this script in one
CODE
default
{
touch_start(integer total_number)
{
// sends the message 0, "Touched.", NULL_KEY to the same object that contains this script.
// (llGetLinkNumber() gets the linknum.)
llMessageLinked(llGetLinkNumber(), 0, "Touched.", "");
}
}

and this in the other

CODE


default
{
link_message(integer sender_num, integer num, string str, key id)
{
llSay(0,str);
}
}

and hoped I'd get a response from something, Then tried making the other one the main prim no difference.
Well what good is an example if when you try it you get no response?
Someone please point out what I'm doing wrong here both scripts compiled succsfully, are running and I even tried adding this line to one to see if It made it.
llSay(0,"made it to here";);

CODE

default
{
link_message(integer sender_num, integer num, string str, key id)
{
llSay(0,str);
llSay(0,"made it to here");
}
}

and never got a peep
and if you know how to do what i'm trying to do could you show me an example. or get a hold of me and sell it to me?
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
08-24-2004 13:35
The problem is in your call to llMessageLinked.

The first parameter should be the link number of the intended *recipients*. You've specified llGetLinkNumber(), which will return the link number of the current prim. It's sending a link message to itself, and no one else.

Replace llGetLinkNumber() with the predefined constant LINK_SET (or LINK_ALL_OTHERS or LINK_ALL_CHILDREN). Then it ought to work.
Tigsen Fairplay
Registered User
Join date: 23 Aug 2004
Posts: 16
08-24-2004 13:57
I think you want both prim's connected (sorry, I'm still new to this language and how stuff works, so I may be using the wrong terminology) so that they are effectively 1 object. Then to send a message to all scripts associated with prims that are part of the larger object you use:

llMessageLinked(integer linknum, integer num, string str, key id);

Where linknum would be set to the constant of LINK_SET (all objects). In other words, you might have something like this on the prim that is touched:

CODE

default
{
state_entry()
{
llSay(0, "Entry state set.");
}

touch_start(integer total_number)
{
llSay(0,"Primary prim has been touched.");

// Send a linked message with the number 5, "some string",
// and the key of the avatar that touched the prim.
llMessageLinked(LINK_SET, 5, "some string", llDetectedKey(0));
}
}


Now, the script that goes on the second prim (which you've linked/grouped to the primary prim) would be:

CODE

default
{
state_entry()
{
llSay(0, "Entry state set.");
}

link_message(integer senders_num, integer some_integer, string a_string, key avatar_key_id)
{
llSay(0,"A link message was received! The data transferred was:");
llSay(0,"Sender's number: " + (string)senders_num);
llSay(0,"Integer: " + (string)some_integer);
llSay(0,"String: " + a_string);
llSay(0,"key: " + (string)avatar_key_id);
}
}


Note: I've not tested the above script, but I do believe it would work base don what I've been reading of the linked_message function. Of course, your second prim that receives the message could do whatever it wanted with the message... such as checking the value of num and taking some action based on that... one of the possible values could be one to indicate a texture change, in which case the new texture to use could be sent via the string variable.

Hope this helps,
Tigsen
RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
08-24-2004 15:38
Thank you that works
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
08-25-2004 08:04
I fixed up the example in the wiki, the wanted function is llDetectedLinkNumber.
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!