Difference between revisions of "LlMessageLinked"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|func_id=164
|func_id=164|func_sleep=0.0|func_energy=10.0
|func_sleep=0.0
|func=llMessageLinked|sort=MessageLinked
|func_energy=10.0
|p1_type=integer|p1_name=linknum|p1_desc=Link number or a LINK_* flag.
|func=llMessageLinked
|p2_type=integer|p2_name=num
|p1_type=integer
|p3_type=string|p3_name=str
|p1_name=linknum
|p4_type=key|p4_name=id
|p2_type=integer
|func_desc=Sends '''num''', '''str''', and '''id''' to link '''linknum''' or the group '''linknum'''.
|p2_name=num
|constants={{{!}} {{Prettytable}}
|p3_type=string
!Flag
|p3_name=str
!Value
|p4_type=key
!Description
|p4_name=id
{{!}}-
|func_footnote=Sends num, str, and id to members of the link set (LINK_ROOT sends to root task in a linked set,<br/>LINK_SET sends to all tasks,<br />LINK_ALL_OTHERS to all other tasks,<br/>LINK_ALL_CHILDREN to all children,<br />LINK_THIS to the task the script it is in)|return_text
{{!}} {{LSLG|LINK_ROOT}}
{{!}} 1
{{!}} sends to root task in a linked set
{{!}}-
{{!}} {{LSLG|LINK_SET}}
{{!}} -1
{{!}} sends to all tasks
{{!}}-
{{!}} {{LSLG|LINK_ALL_OTHERS}}
{{!}} -2
{{!}} sends to all other tasks
{{!}}-
{{!}} {{LSLG|LINK_ALL_CHILDREN}}
{{!}} -3
{{!}} sends to all children
{{!}}-
{{!}} {{LSLG|LINK_THIS}}
{{!}} -4
{{!}} sends to the task the script it is in
{{!}}}
|func_footnote
|return_text
|spec
|spec
|caveats
|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=<lsl>
|examples=<pre>
default{ // assumptions  // object name: LSLWiki // script name: _lslwiki
default{ // assumptions  // object name: LSLWiki // script name: _lslwiki
    state_entry() {
    state_entry() {
      llMessageLinked(LINK_THIS,0,llGetScriptName(),NULL_KEY)
        llMessageLinked(LINK_THIS,0,llGetScriptName(),NULL_KEY)
    }
    }


    link_message(integer sender_num, integer num, string msg, key id) {
    link_message(integer sender_num, integer num, string msg, key id) {
      llOwnerSay(msg);
        llOwnerSay(msg);
      // the owner of object LSLWiki will hear
        // the owner of object LSLWiki will hear
      // LSLWiki:_lslwiki
        // LSLWiki:_lslwiki
    }     
    }     
}
}
</lsl>
|helpers
|related
|also
|notes=
<pre>
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 infite loops based a script reacting to a
linked message by sending a linked message, to which it reacts.
</pre>
</pre>
|helpers=<pre>
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]));
    }   
}
</pre>
|also_header
|also_events
|also_functions
|also_articles
|also_footer
|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.
|cat1=Communications
|cat2
|cat3
|cat4
}}
}}
[[Category:LSL_Functions]]
[[Category:LSL_Stub]]

Revision as of 23:00, 11 February 2007

Summary

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

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.
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.

Deep Notes

Search JIRA for related Issues

Signature

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