Difference between revisions of "Link Messages"

From Second Life Wiki
Jump to navigation Jump to search
(reformetted to shorten line length)
m (Avoid line overflow)
Line 8: Line 8:
{
{
     touch_start(integer touched)  
     touch_start(integer touched)  
     {
     { //When someone touches this, send the message "touched",
        llMessageLinked(LINK_SET, 0, "touched", llDetectedKey(0)); //When someone touches this, send the message "touched",
      //the number 0 and the avatar's key who touched this prim
                                                                  //the number 0 and the avatar who touched this prim's key
      //to all scripts in this linkset.
                                                                  //to all scripts in this linkset.
 
        llMessageLinked(LINK_SET, 0, "touched", llDetectedKey(0));   
     }
     }
}
}
Line 21: Line 22:
{
{
     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  
                  //When this prim receives a message, say to the owner what it received.
            + " within this linkset. The Message is the number "
            + (string)Number + ", the message " + Text + ", and the key of the avatar "  
            + llKey2Name(ID) + ".");
     }
     }
}
}

Revision as of 05:47, 7 September 2007

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