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

From Second Life Wiki
Jump to navigation Jump to search
(Created page with ''''NewAge Auto Unpacker v1.0''' Just copy and paste this script into your object that will contain your product and configure the few lines in // Configure; section <lsl> /////...')
 
m (<lsl> tag to <source>)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''NewAge Auto Unpacker v1.0'''
'''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
Just copy and paste this script into your object that will contain your product and configure the few lines in // Configure; section


<lsl>
<source lang="lsl2">
/////////////////////////////////
// NewAge Auto Unpacker Script
// NewAge Auto Unpacker Script
// By Asia Snowfall
// By Asia Snowfall
// Version 1.0
/////////////////////////////////


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


string Folder_Name = "New Folder"; // This will be the name of the folder sent to the user
init()
 
string Show_Name_Of_Folder_On_Completion = "Yes"; // Change to No to not show the folder name when sent
 
string Show_Name_Message_On_Completion = "Folder will be named <folder>"; // If you have sent Show_Name_Of_Folder_On_Completion to Yes, change this message to however you want, Where you place the tag <folder> is where it will show folder name
 
string Message_On_Rez = "Sending your package now..."; // Message sent when object is rezzed
 
string Message_On_Sent_Completion = "Your package has been sent to you"; // Message sent when sending is complete
 
string Send_This_Script_To_Package_Owner = "yes"; // Change to yes if you want this script to be sent to the user within the package folder
 
string Delete_On_Completion = "Yes"; // Change to no if you don't want the object to delete itself after package is sent
 
/////////////////////////////////
integer INVENTORY_TYPE = INVENTORY_ALL;
 
 
/////////////////////////////////
 
key llGetObjectOwner()
{
{
     list details = llGetObjectDetails(llGetKey(), [OBJECT_OWNER]);
     nameOfFolderToBeCreated      = llGetObjectName();//  do not use an empty string
     return (key)llList2CSV(details);
    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;
}
}


llSendInventory(key id, integer inventory_type)
try_to_send_items(key inputKey, integer inputType)
{
{
     integer i = 0;
     integer numberOfItems = llGetInventoryNumber(inputType);
     integer items = llGetInventoryNumber(inventory_type);
     string  thisScript    = llGetScriptName();
     list to_send;
    string  itemName;
     string name;
     list   listOfItemsToSend;
 
     integer index;
     do
     do
     {
     {
         name = llGetInventoryName(inventory_type, i);
         itemName = llGetInventoryName(inputType, index);
         if(llStringLength(name) > 0)
 
         if(itemName != "")
         {
         {
             if(name == llGetScriptName() && llToLower(Send_This_Script_To_Package_Owner) == "yes")
             if(addThisScriptToFolder && itemName == thisScript)
            {
                 listOfItemsToSend += [itemName];
                 to_send += name;
 
            }
             else if(itemName != thisScript)
             else if(name != llGetScriptName())
                 listOfItemsToSend += [itemName];
            {
                 to_send += name;
            }
         }
         }
     }while(i++<items);
     }
     llGiveInventoryList(llGetObjectOwner(), Folder_Name, to_send);
    while(++index < numberOfItems);
     llInstantMessage(llGetObjectOwner(), Message_On_Sent_Completion);
 
//  change to number of items in list now
    numberOfItems = llGetListLength(listOfItemsToSend);
 
     if(numberOfItems)
    {
        llGiveInventoryList(inputKey, nameOfFolderToBeCreated, 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
default
{
{
     on_rez(integer x)
     on_rez(integer start_param)
     {
     {
         llInstantMessage(llGetObjectOwner(), Message_On_Rez);
         init();
        llSendInventory(llGetObjectOwner(), INVENTORY_TYPE);
 
         if(llToLower(Show_Name_Of_Folder_On_Completion) == "yes")
         key owner = llGetOwner();
        {
 
            integer index = llSubStringIndex(Show_Name_Message_On_Completion, "<folder>");
        if (messageToSendUponRez != "")
            string message;
             llInstantMessage(owner, messageToSendUponRez);
            if(index != -1)
 
             {
        try_to_send_items(owner, typeOfInventoryItemsToBeSent);
                message = llDeleteSubString(Show_Name_Message_On_Completion, index, index + llStringLength(Show_Name_Message_On_Completion)-1);
 
                message += Folder_Name;
         if (killAfterCompletion)
            }
            else
            {
                message = Show_Name_Message_On_Completion;
            }
            llInstantMessage(llGetObjectOwner(), message);
        }
         if(llToLower(Delete_On_Completion) == "yes")
        {
             llDie();
             llDie();
        }
     }
     }
}
}
</lsl>
</source>

Latest revision as of 10:15, 25 January 2015

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

//  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, nameOfFolderToBeCreated, 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();
    }
}