Difference between revisions of "Link Messages"

From Second Life Wiki
Jump to navigation Jump to search
m (Avoid line overflow)
m (lsl code tagging)
Line 4: Line 4:


=====Script to Send a Message=====
=====Script to Send a Message=====
<pre>
<lsl>
default  
default  
{
{
Line 15: Line 15:
     }
     }
}
}
</pre>
</lsl>


=====Script to Receive the Message=====
=====Script to Receive the Message=====
<pre>
<lsl>
default  
default  
{
{
Line 30: Line 30:
     }
     }
}
}
</pre>
</lsl>


[[Category:LSL Examples]]
[[Category:LSL Examples]]

Revision as of 16:08, 30 March 2008

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

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

} </lsl>

Script to Receive the Message

<lsl> 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) + ".");
   }

} </lsl>