The purpose of this function is to allow scripts in the same object to communicate. It triggers a link_message event with the same parameters num, str, and id in all scripts in the prim(s) described by link.
void llMessageLinked( integer link, integer num, string str, key id );
Forced delay: 0.0 seconds. Energy: 10.0.
LINK_* flag, controls which prim(s) receive the link_message.You can use id as a second string field[2]. The sizes of str and id are only limited by available script memory.
|
|
|||||||||||||||||||||
LINK_* flags and can cause script execution to slow or halts.default
{
// assumptions // object name: LSLWiki // script name: _lslwiki
state_entry()
{
llMessageLinked(LINK_THIS, 0, llGetScriptName(), "");
}
link_message(integer sender_num, integer num, string msg, key id)
{
llOwnerSay(msg);
// the owner of object LSLWiki will hear
// LSLWiki:_lslwiki
}
}
Message_Control(integer l, integer n) // Message_Total_Lack_Of_Control
{
integer r = (++n); // Increment the value of n.
llMessageLinked( l, r, "", ""); // Send the result to l
}
default
{
state_entry()
{
Message_Control(LINK_SET, 0); // Tell all the scripts in the object that we have state_entered.
}
link_message(integer Sender, integer Number, string String, key Key) // This script is in the object too.
{
Message_Control(Sender, Number); // No filtering condition exists.
llOwnerSay(((string)Number)); // Look at all the pretty numbers!
}
}
default
{
// Quick and dirty debugging link_messages
link_message(integer sender_num, integer num, string msg, key id)
{
llSay(DEBUG_CHANNEL, llList2CSV([sender_num, num, msg, id]));
}
}
// This is just an example script, you shouldn't handle link message within single script this way.
default
{
// To propagate an unlimted number of arguments of any type.
// Presumed, the separator string isn't used in any source string!
state_entry()
{
list my_list = [1, 2.0, "a string", <1, 2, 3>, <1, 2, 3, 4>, llGetOwner()];
string list_parameter = llDumpList2String(my_list, "|"); // Convert the list to a string
llMessageLinked(LINK_THIS, 0, list_parameter, "");
}
link_message(integer sender_num, integer num, string list_argument, key id)
{
list re_list = llParseString2List(list_argument, ["|"], []); // Parse the string back to a list
}
}
Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.
When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating all avatars first.
There are two functions of interest when trying to find the number of prims and avatars on an object.
llGetNumberOfPrims() - Returns the number of prims and seated avatars.llGetObjectPrimCount(llGetKey()) - Returns only the number of prims in the object but will return zero for attachments.integer GetPrimCount() { //always returns only the number of prims
if(llGetAttached())//Is it attached?
return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}See llGetNumberOfPrims for more about counting prims and avatars.
If a script located in a child prim erroneously attempts to access link 0, it will get or set the property of the linkset's root prim. This bug (BUG-5049) is preserved for broken legacy scripts.
.25 to .50 delay between receiving and sending of llMessageLinked has been observed by some users