Difference between revisions of "Link Messages"
Jump to navigation
Jump to search
Gigs Taggart (talk | contribs) m (LSL Example Link Messages moved to Link Messages) |
m (Replaced <source> with <syntaxhighlight>) |
||
(7 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{LSL Header}} | {{LSL Header|ml=*}} | ||
====Link Messages==== | ====Link Messages==== | ||
Link Messages are used to communicate between 2(or more) prims in the same linkset, or even between 2 (or more) scripts within the same prim. This is just a brief example of how to use them | Link Messages are used to communicate between 2(or more) prims in the same linkset, or even between 2 (or more) scripts within the same prim. This is just a brief example of how to use them | ||
=====Script to Send a Message===== | =====Script to Send a Message===== | ||
< | <syntaxhighlight lang="lsl2"> | ||
default | default | ||
{ | { | ||
touch_start(integer touched) | touch_start(integer touched) | ||
{ | { //When someone touches this, send the message "touched", | ||
//the number 0 and the avatar's key who touched this prim | |||
//to all scripts in this linkset. | |||
llMessageLinked(LINK_SET, 0, "touched", llDetectedKey(0)); | |||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
=====Script to Receive the Message===== | =====Script to Receive the Message===== | ||
< | <syntaxhighlight lang="lsl2"> | ||
default | default | ||
{ | { | ||
link_message(integer Sender, integer Number, string Text, key ID) | link_message(integer Sender, integer Number, string Text, key ID) | ||
{ | { //When this prim receives a message, say to the owner what it received. | ||
llOwnerSay("Message received from prim number " + (string)Sender + " within this linkset. The Message is the number " + (string)Number + ", the message " + Text + ", and the key of the avatar " + llKey2Name(ID) + "."); | |||
llOwnerSay("Message received from prim number " + (string)Sender | |||
+ " within this linkset. The Message is the number " | |||
+ (string)Number + ", the message " + Text + ", and the key of the avatar " | |||
+ llKey2Name(ID) + "."); | |||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
[[Category:LSL Examples]] |
Latest revision as of 15:15, 23 April 2022
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Link Messages
Link Messages are used to communicate between 2(or more) prims in the same linkset, or even between 2 (or more) scripts within the same prim. This is just a brief example of how to use them
Script to Send a Message
default
{
touch_start(integer touched)
{ //When someone touches this, send the message "touched",
//the number 0 and the avatar's key who touched this prim
//to all scripts in this linkset.
llMessageLinked(LINK_SET, 0, "touched", llDetectedKey(0));
}
}
Script to Receive the Message
default
{
link_message(integer Sender, integer Number, string Text, key ID)
{ //When this prim receives a message, say to the owner what it received.
llOwnerSay("Message received from prim number " + (string)Sender
+ " within this linkset. The Message is the number "
+ (string)Number + ", the message " + Text + ", and the key of the avatar "
+ llKey2Name(ID) + ".");
}
}