Difference between revisions of "Unpacker On Rez (NewAge)"

From Second Life Wiki
Jump to navigation Jump to search
m (some minor improvements)
m
Line 4: Line 4:


<lsl>
<lsl>
// NewAge Auto Unpacker Script
// NewAge Auto Unpacker Script
// By Asia Snowfall
// By Asia Snowfall
string nameOfFolderToBeCreated;
 
string messageToSendUponRez;
string nameOfFolderToBeCreated;
string messageToSendUponRez;
integer addThisScriptToFolder;
integer addThisScriptToFolder;
integer typeOfInventoryItemsToBeSent;
integer typeOfInventoryItemsToBeSent;
Line 14: Line 15:
init()
init()
{
{
//  do not use an empty string
    nameOfFolderToBeCreated      = llGetObjectName();//  do not use an empty string
     nameOfFolderToBeCreated = llGetObjectName();
     messageToSendUponRez        = "";//  leave empty to not send a message upon rez
 
     typeOfInventoryItemsToBeSent = INVENTORY_ALL;//  use INVENTORY_ALL to not apply a filter
//  leave empty to not send a message upon rez
     addThisScriptToFolder       = FALSE;
     messageToSendUponRez = "";
     killAfterCompletion         = TRUE;
 
//  use INVENTORY_ALL to not apply a filter
    typeOfInventoryItemsToBeSent = INVENTORY_ALL;
 
     addThisScriptToFolder = FALSE;
 
     killAfterCompletion = TRUE;
}
}


Line 31: Line 25:
{
{
     integer numberOfItems = llGetInventoryNumber(inputType);
     integer numberOfItems = llGetInventoryNumber(inputType);
    string  thisScript    = llGetScriptName();
    string  itemName;
    list    listOfItemsToSend;


    string thisScript = llGetScriptName();
     integer index;
    string itemName;
    list listOfItemsToSend;
 
     integer i;
     do
     do
     {
     {
         itemName = llGetInventoryName(inputType, i);
         itemName = llGetInventoryName(inputType, index);


         if(itemName != "")
         if(itemName != "")
Line 50: Line 43:
         }
         }
     }
     }
     while(++i < numberOfItems);
     while(++index < numberOfItems);


//  change to number of items in list now
//  change to number of items in list now
Line 71: Line 64:
     on_rez(integer start_param)
     on_rez(integer start_param)
     {
     {
        init();
         key owner = llGetOwner();
         key owner = llGetOwner();



Revision as of 04:28, 21 January 2014

NewAge Auto Unpacker v1.1

Just copy and paste this script into your object that will contain your product and configure the few lines in // Configure; section

<lsl> // NewAge Auto Unpacker Script // By Asia Snowfall

string nameOfFolderToBeCreated; string messageToSendUponRez; integer addThisScriptToFolder; integer typeOfInventoryItemsToBeSent; integer killAfterCompletion;

init() {

   nameOfFolderToBeCreated      = llGetObjectName();//  do not use an empty string
   messageToSendUponRez         = "";//  leave empty to not send a message upon rez
   typeOfInventoryItemsToBeSent = INVENTORY_ALL;//  use INVENTORY_ALL to not apply a filter
   addThisScriptToFolder        = FALSE;
   killAfterCompletion          = TRUE;

}

try_to_send_items(key inputKey, integer inputType) {

   integer numberOfItems = llGetInventoryNumber(inputType);
   string  thisScript    = llGetScriptName();
   string  itemName;
   list    listOfItemsToSend;
   integer index;
   do
   {
       itemName = llGetInventoryName(inputType, index);
       if(itemName != "")
       {
           if(addThisScriptToFolder && itemName == thisScript)
               listOfItemsToSend += [itemName];
           else if(itemName != thisScript)
               listOfItemsToSend += [itemName];
       }
   }
   while(++index < numberOfItems);

// change to number of items in list now

   numberOfItems = llGetListLength(listOfItemsToSend);
   if(numberOfItems)
   {
       llGiveInventoryList(inputKey, nameOfCreatedFolder, listOfItemsToSend);
       llInstantMessage(inputKey,
                   "/me [" + thisScript + "]: Items have been sent into a folder named '"
                   + nameOfFolderToBeCreated + "' within your inventory.");
   }
   else
       llInstantMessage(inputKey,
           "/me [" + thisScript + "]: Could not find inventory items to send!");

}

default {

   on_rez(integer start_param)
   {
       init();
       key owner = llGetOwner();
       if (messageToSendUponRez != "")
           llInstantMessage(owner, messageToSendUponRez);
       try_to_send_items(owner, typeOfInventoryItemsToBeSent);
       if (killAfterCompletion)
           llDie();
   }

} </lsl>