LSL Wiki Mirror 10-5-2006: llMessageLinked

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
llMessageLinked(integer linknum, integer num, string str, key id)

Sends num, str, and id to linknum (the specific prim in the linked set).

The value for linknum can be the link number of the desired prim (use llGetLinkNumber to get the prim's link number containing the script) or one of the constants for linked sets.

Constants

Constant Value Description
LINK_ROOT 1 root prim in linked set (but not in a single prim, which is 0)
LINK_SET -1 all prims in object
LINK_ALL_OTHERS -2 all other prims in object besides prim function is in
LINK_ALL_CHILDREN -3 all child prims in object
LINK_THIS -4 prim script is in

In objects with only 1 prim, linknum is 0. In objects with multiple prims, the linknum count starts at 1. (So in a 2-prim object, llGetLinkNumber would return 1 in the parent and 2 in the child.

num can be any valid integer. Depending on the filter setup for link_message, num may not be necessary.

str and id may be blank, ("") or as long as desired. str and id are only limited by the amount of available memory.

Notes:

llMessageLinked triggers the link_message event handler in scripts receiving link messages.

Example:
See ExampleLinkMessage.

Q: I don't get it. Why not just use chat?
A: Aside from the fact that an object can't listen to itself, link messages are much faster than using chat functions as well as being private. They're higher-capacity, avoiding chat's 255-character limitations, and use fewer prims. Also, if you tend to have memory overflow problems in a single script, you can use link messages to communicate between scripts in the same object, thus enabling separate storage or even pseudo-multithreading. And finally, as any type can be cast to a string, link messages can transfer all types of data.

Additional testing on 2/1/2005 has shown link messages to be up to 40% faster than llWhisper calls.
This is because llSay, llShout, and llWhisper all have penalties built into them, llMessageLinked does not. -- Ice

Q: Can I use llMessageLinked to send a message within only one script?
A: Yes, though there are better ways to communicate within a single script. Note that your link_message event will trigger on all link messages the prim receives, so your script may end up talking to itself if you're not careful.

Q: Do I need to specify a value for num, str, and id, or can I use a null string or key?
A: No, you can give llMessageLinked empty values of 0, "" and NULL_KEY, respectively.

Q: Can I use link messages to communicate between two attachments, or an attachment and the object the avatar is sitting on?
A: No, they're not truly linked in this case. You'll need to use chat instead.


Functions | Communications | Link
There are 5 comments on this page. [Display comments/form]