User:Toy Wylie/RLV Documentation/getattach

From Second Life Wiki
< User:Toy Wylie‎ | RLV Documentation
Revision as of 05:14, 9 July 2010 by Toy Wylie (talk | contribs) (notes section)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


@getattach

Type

General

Implemented

Implemented since RLV version 1.10

Usage

@getattach[:attachmentpoint]=<channel>

Purpose

Gets a list of attachments present on the avatar. The list will be sent as chat to the specified channel. The response is a string of "0" and "1", "0" meaning, the attachment point is empty, "1" meaning, the attachment point is occupied. The index of the number in the string corresponds to the ATTACH_* constants used in LSL. This means that the first index in the response (index 0) will always be "0", because there is no attachment point with the number 0. If an attachment point is specified it returns only the status of this single attachment point. No extra "0" will be present here.

Notes

* Make sure to have a timeout while waiting for the list to appear, because viewers without RLV won't answer this query at all.

See Also

Example

<lsl>integer channel;

integer listener;

list attachmentPoints= [

   "chest","skull","left shoulder","right shoulder","left hand",
   "right hand","left foot","right foot","spine","pelvis","mouth",
   "chin","left ear","right ear","left eyeball","right eyeball","nose",
   "r upper arm","r forearm","l upper arm","l forearm","right hip",
   "r upper leg","r lower leg","left hip","l upper leg","l lower leg",
   "stomach","left pec","right pec","center 2","top right","top",
   "top left","center","bottom left","bottom","bottom right"

];

removeListener() {

   if(listener!=0)
   {
       llListenRemove(listener);
       listener=0;
   }
   llSetTimerEvent(0.0);

}

default {

   state_entry()
   {
       listener=0;
       llOwnerSay("Touch me to find out which attachment points are occupied.");
   }
   touch_start(integer total_number)
   {
       if(listener!=0)
       {
           llOwnerSay("We are already looking for attachments. Please wait for the scan to finish.");
           return;
       }
       channel=(integer) (llFrand(100000)+100000);
       listener=llListen(channel,"",llDetectedKey(0),"");
       llSetTimerEvent(5.0);
       llOwnerSay("Scanning for attachments ...");
       llOwnerSay("@getattach="+(string) channel);
   }
   listen(integer channel,string name,key sender,string message)
   {
       removeListener();
       integer index;
       integer len=llGetListLength(attachmentPoints);
       // start with 1 because index 0 is not used
       for(index=1;index<len;index++)
       {
           if(llGetSubString(message,index,index)=="1")
           {
               string name=llList2String(attachmentPoints,index-1);
               llOwnerSay("Attachment point '"+name+"' is occupied.");
           }
       }
       llOwnerSay("Scan complete.");
   }
   timer()
   {
       removeListener();
       llOwnerSay("Scan timeout. You are probably not using RLV.");
   }

}

</lsl>