Difference between revisions of "MLPV2 Give Items in Folder to a Specific Person"

From Second Life Wiki
Jump to: navigation, search
(Created page with "<lsl> //add-on by Chaz Longstff for MLPV2 by Lear Cale. August 2011. Give 2 v.001 //Function: gives object to a specific person on an MLPV2 ball // //in a menu card, format a men…")
 
Line 4: Line 4:
 
//
 
//
 
//in a menu card, format a menu button like this, for example:
 
//in a menu card, format a menu button like this, for example:
//LINKMSG MyButtonName | 0,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##FolderName##Wear these four cuffs.##0
+
//LINKMSG MyButtonName | 0,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##FolderName##0##0Wear these four cuffs.
 
//In this example, MyButtonName is the button name
 
//In this example, MyButtonName is the button name
 
//0 means whether to make the MLPV2 menu go away or not. Generally set it to 0 as per the example, so the menu comes back (taking advantage of new 2.x and higher viewers). To make the MLPV2 menu go away, use 1 instead.
 
//0 means whether to make the MLPV2 menu go away or not. Generally set it to 0 as per the example, so the menu comes back (taking advantage of new 2.x and higher viewers). To make the MLPV2 menu go away, use 1 instead.
Line 10: Line 10:
 
//987789 -- don't change this, this is the communication channel
 
//987789 -- don't change this, this is the communication channel
 
//Cuff1#Cuff2#Cuff3#Cuff4 -- (The items to give are separated by a single #  
 
//Cuff1#Cuff2#Cuff3#Cuff4 -- (The items to give are separated by a single #  
//##FolderName: the name of the folder to put the stuff in. Note that it needs to be preceded by a double ##.
+
//##FolderName: the name of the folder to put the stuff in. Note that it needs to be preceded by a double ##.
//##Wear these four cuffs -- Msg to receiver. (Note that it needs to be preceded by a double ##.  It's good to include a msg, so that they don't think it's a griefer trying to hand them something. However, you can leave this param blank if you wish.
+
 
//##0  -- (offer to person on which ball? 0, 1, 2, 3, 4, 5 . You can leave blank if the person to receive is the person who is operating the menu, this is default behaviour.)
 
//##0  -- (offer to person on which ball? 0, 1, 2, 3, 4, 5 . You can leave blank if the person to receive is the person who is operating the menu, this is default behaviour.)
 +
//##Wear these four cuffs -- Msg to receiver. (Note that it needs to be preceded by a double ##.  It's good to include a msg, so that they don't think it's a griefer trying to hand them something. However, you can leave this param blank if you wish.
 +
//Caution: There is a linden script limit of 255 bytes of info that can be read from a notecard line. Practically speaking, that means you are limited to say maybe 225, 230 characters in total that you can have in this LINKMSG line. So if you are giving several items to wear in one folder, keep the items names short and sweet, or your whole line will get truncated randomly, just cut right off.
 
   
 
   
 
//parameters  
 
//parameters  
Line 20: Line 21:
 
list    Avnames = ["", "", "", "", "", ""];
 
list    Avnames = ["", "", "", "", "", ""];
 
key GiveToID;
 
key GiveToID;
 +
string FolderName;
  
  
Line 28: Line 30:
 
removeAv(integer ballIx) {
 
removeAv(integer ballIx) {
 
     addAv("", ballIx);
 
     addAv("", ballIx);
 +
}
 +
 +
myMsg() {
 +
    string name = llGetObjectName();
 +
    llSetObjectName("Blue Balls");
 +
    //change the text "Blue Balls" to anything you like, such as your own Brand Name
 +
    llInstantMessage(GiveToID,message + " " + FolderName);
 +
    if (name != "") llSetObjectName(name);
 
}
 
}
 
//_________________________
 
//_________________________
Line 49: Line 59:
 
         }
 
         }
 
       else if (num == 987789) {
 
       else if (num == 987789) {
 +
          //llSay(0, "test:" + str);
 
             string idtogiveto = "";
 
             string idtogiveto = "";
 
             list TempList = llParseStringKeepNulls(str,["##"],[]);
 
             list TempList = llParseStringKeepNulls(str,["##"],[]);
Line 54: Line 65:
 
             list ObjectsToGive = llParseStringKeepNulls(Objects,["#"],[]);
 
             list ObjectsToGive = llParseStringKeepNulls(Objects,["#"],[]);
 
             integer GiveLength = llGetListLength(ObjectsToGive);
 
             integer GiveLength = llGetListLength(ObjectsToGive);
             string FolderName = llStringTrim(llList2String(TempList, 1),STRING_TRIM);
+
             FolderName = llStringTrim(llList2String(TempList, 1),STRING_TRIM);
             message = llStringTrim(llList2String(TempList, 2),STRING_TRIM);
+
             string ball = llStringTrim(llList2String(TempList, 2),STRING_TRIM);
             string ball = llStringTrim(llList2String(TempList, 3),STRING_TRIM);
+
             message = llStringTrim(llList2String(TempList, 3),STRING_TRIM);
 +
           
 
             if (ball != "") {
 
             if (ball != "") {
 
                 idtogiveto = llStringTrim(llList2String(Avnames,(integer)ball),STRING_TRIM);
 
                 idtogiveto = llStringTrim(llList2String(Avnames,(integer)ball),STRING_TRIM);
Line 69: Line 81:
 
             if (GiveLength != 0) {
 
             if (GiveLength != 0) {
 
                 if (message != "") {
 
                 if (message != "") {
                   llInstantMessage(GiveToID,message + " " + llList2CSV(ObjectsToGive));
+
                   myMsg();
 
                 }
 
                 }
 
             llGiveInventoryList(GiveToID, FolderName, ObjectsToGive);
 
             llGiveInventoryList(GiveToID, FolderName, ObjectsToGive);
Line 78: Line 90:
 
} //end default state
 
} //end default state
 
   
 
   
 +
  
 
</lsl>
 
</lsl>

Revision as of 18:17, 10 September 2011

<lsl> //add-on by Chaz Longstff for MLPV2 by Lear Cale. August 2011. Give 2 v.001 //Function: gives object to a specific person on an MLPV2 ball // //in a menu card, format a menu button like this, for example: //LINKMSG MyButtonName | 0,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##FolderName##0##0Wear these four cuffs. //In this example, MyButtonName is the button name //0 means whether to make the MLPV2 menu go away or not. Generally set it to 0 as per the example, so the menu comes back (taking advantage of new 2.x and higher viewers). To make the MLPV2 menu go away, use 1 instead. //-4 -- the value of LINK_THIS, meaning, send this message to this prim only. (Use -1 if the ~give2 script is in a different prim.) //987789 -- don't change this, this is the communication channel //Cuff1#Cuff2#Cuff3#Cuff4 -- (The items to give are separated by a single # //##FolderName: the name of the folder to put the stuff in. Note that it needs to be preceded by a double ##. //##0 -- (offer to person on which ball? 0, 1, 2, 3, 4, 5 . You can leave blank if the person to receive is the person who is operating the menu, this is default behaviour.) //##Wear these four cuffs -- Msg to receiver. (Note that it needs to be preceded by a double ##. It's good to include a msg, so that they don't think it's a griefer trying to hand them something. However, you can leave this param blank if you wish. //Caution: There is a linden script limit of 255 bytes of info that can be read from a notecard line. Practically speaking, that means you are limited to say maybe 225, 230 characters in total that you can have in this LINKMSG line. So if you are giving several items to wear in one folder, keep the items names short and sweet, or your whole line will get truncated randomly, just cut right off.

//parameters string ObjectToGive; string message; integer x; list Avnames = ["", "", "", "", "", ""]; key GiveToID; string FolderName;


addAv(string id, integer ballIx) {

   Avnames = llListReplaceList(Avnames, (list)id, ballIx, ballIx);

}

removeAv(integer ballIx) {

   addAv("", ballIx);

}

myMsg() {

   string name = llGetObjectName();
   llSetObjectName("Blue Balls");
   //change the text "Blue Balls" to anything you like, such as your own Brand Name
   llInstantMessage(GiveToID,message + " " + FolderName);
   if (name != "") llSetObjectName(name);

} //_________________________ default{

  link_message(integer from, integer num, string str, key id) { 
  
   if (num == -11000) {
           // av hopped on
           list parms = llParseStringKeepNulls(str, ["|"], []);
           integer ballnum = (integer)llList2String(parms, 0);
           // string anim = llList2String(parms, 1);     // anim name parameter, if desired
           //debug(4, llKey2Name(dkey) + ": on ball " + (string)ballnum);
           addAv((string)id, ballnum);
           return;
       } else if (num == -11001) {
           // av hopped off
           //debug(4, llKey2Name(dkey) + ": off ball " + str);
           removeAv((integer)str);
           return;
       }
      else if (num == 987789) {
          //llSay(0, "test:" + str);
           string idtogiveto = "";
           list TempList = llParseStringKeepNulls(str,["##"],[]);
           string Objects = llStringTrim(llList2String(TempList, 0),STRING_TRIM);
           list ObjectsToGive = llParseStringKeepNulls(Objects,["#"],[]);
           integer GiveLength = llGetListLength(ObjectsToGive);
           FolderName = llStringTrim(llList2String(TempList, 1),STRING_TRIM);
           string ball = llStringTrim(llList2String(TempList, 2),STRING_TRIM);
           message = llStringTrim(llList2String(TempList, 3),STRING_TRIM);
           
           if (ball != "") {
               idtogiveto = llStringTrim(llList2String(Avnames,(integer)ball),STRING_TRIM);
           }
           //llSay(0, idtogiveto);
           if (idtogiveto == "") {
               GiveToID = id;
               //llSay(0, (string)GiveToID);
           }
           
           else GiveToID = (key)idtogiveto;
           if (GiveLength != 0) {
               if (message != "") {
                  myMsg();
               }
           llGiveInventoryList(GiveToID, FolderName, ObjectsToGive);
           }//end of checking GiveLength
      } //end of if check for the right channel
  } //end link_message event

} //end default state


</lsl>