Difference between revisions of "Link message"

From Second Life Wiki
Jump to navigation Jump to search
(Added snippet how to use list type parameter)
Line 10: Line 10:
|examples=
|examples=
<pre>
<pre>
//This is just an example script, you shouldn't handle touches within in single script this way.
//This is just an example script, you shouldn't handle touches within single script this way.
 
default
default
{
{
Line 23: Line 24:
}
}
</pre>
</pre>
|helpers
|helpers=<pre>
// 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, "|"); // Typecast list to a string
        llMessageLinked(LINK_THIS, 0, list_parameter, NULL_KEY)
    }
 
    link_message(integer sender_num, integer num, string list_argument, key id) {
        list re_list = llParseString2List(list_argument, ["|"], [""]); // Typecast string back to a list
    }   
}
</pre>
|also_header
|also_header
|also_events
|also_events

Revision as of 02:48, 7 September 2007

Description

Event: link_message( integer sender_num, integer num, string str, key id ){ ; }

Triggered when task receives a link message via llMessageLinked library function call

• integer sender_num
• integer num
• string str
• key id

Caveats

  • 64 link_message events can queue, past that, they are silently dropped! Don't do too much in the event if they might be coming in fast.
All Issues ~ Search JIRA for related Bugs

Examples

//This is just an example script, you shouldn't handle touches within single script this way.

default
{
    touch_start(integer c)
    {
        llMessageLinked(LINK_THIS, 0, llDetectedName(0), llDetectedKey(0));
    }
    link_message(integer source, integer num, string str, key id)
    {
        llWhisper(0, str + " (" + (string)id + ") touched me!");
    }
}

Useful Snippets

// 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, "|");	// Typecast list to a string
        llMessageLinked(LINK_THIS, 0, list_parameter, NULL_KEY)
    }

    link_message(integer sender_num, integer num, string list_argument, key id) {
        list re_list = llParseString2List(list_argument, ["|"], [""]);	// Typecast string back to a list
    }    
}

Notes

A script can hear its own link messages.

See Also

Functions

•  llMessageLinked

Deep Notes

Signature

event void link_message( integer sender_num, integer num, string str, key id );