llMessageLinked

From Second Life Wiki
Revision as of 23:01, 11 February 2007 by Strife Onizuka (talk | contribs)
Jump to navigation Jump to search

Summary

Function: llMessageLinked( integer linknum, integer num, string str, key id );
0.0 Forced Delay
10.0 Energy

Sends num, str, and id to link linknum or the group linknum.

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

Flag Value Description
LINK_ROOT 1 sends to root task in a linked set
LINK_SET -1 sends to all tasks
LINK_ALL_OTHERS -2 sends to all other tasks
LINK_ALL_CHILDREN -3 sends to all children
LINK_THIS -4 sends to the task the script it 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.

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.

Deep Notes

Signature

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