llMessageLinked

From Second Life Wiki
Jump to navigation Jump to search

Summary

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

Triggers a link_message event with the parameters num, str, and id in the group or link linknum.

• integer linknum Link number or a LINK_* flag.
• integer num
• string str
• key id

Flag Description
LINK_ROOT 1 sends to the root prim in a multi-prim linked set[1]
LINK_SET -1 sends to all prims
LINK_ALL_OTHERS -2 sends to all other prims
Flag Description
LINK_ALL_CHILDREN -3 sends to all children, (everything but the root)
LINK_THIS -4 sends to the prim the script is in

Caveats

  • It is possible to create infinite loops based on a script reacting to a linked message by sending a linked message, to which it reacts.
All Issues ~ Search JIRA for related Bugs

Examples

default{ // assumptions  // object name: LSLWiki // script name: _lslwiki
    state_entry() {
        llMessageLinked(LINK_THIS,0,llGetScriptName(),NULL_KEY)
    }

    link_message(integer sender_num, integer num, string msg, key id) {
        llOwnerSay(msg);
        // the owner of object LSLWiki will hear
        // LSLWiki:_lslwiki
    }    
}

Useful Snippets

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]));
    }
}

Notes

Using llMessageLinked in a single prim object allows developers to mitigate some LSL limits by, breaking up functionality between cooperating scripts and synchronizing actions. When you do this, be extremely careful not to create infinite loops as mentioned above.

See Also

Events

Deep Notes

Search JIRA for related Issues

Footnotes

  1. ^ LINK_ROOT does not work on single prim objects. Unless there is an avatar sitting on the object.

Signature

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