Difference between revisions of "Unpacker On Rez (NewAge)"
Jump to navigation
Jump to search
m (<lsl> tag to <source>) |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
'''NewAge Auto Unpacker v1. | '''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 | ||
< | <source lang="lsl2"> | ||
// | // NewAge Auto Unpacker Script | ||
// By Asia Snowfall | |||
// 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 | integer numberOfItems = llGetInventoryNumber(inputType); | ||
string thisScript = llGetScriptName(); | |||
list | string itemName; | ||
list listOfItemsToSend; | |||
integer index; | |||
do | do | ||
{ | { | ||
itemName = llGetInventoryName(inputType, index); | |||
if( | |||
if(itemName != "") | |||
{ | { | ||
if( | if(addThisScriptToFolder && itemName == thisScript) | ||
listOfItemsToSend += [itemName]; | |||
else if(itemName != thisScript) | |||
else if( | listOfItemsToSend += [itemName]; | ||
} | } | ||
}while( | } | ||
llGiveInventoryList( | while(++index < numberOfItems); | ||
llInstantMessage( | |||
// 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 | on_rez(integer start_param) | ||
{ | { | ||
init(); | |||
key owner = llGetOwner(); | |||
if (messageToSendUponRez != "") | |||
llInstantMessage(owner, messageToSendUponRez); | |||
try_to_send_items(owner, typeOfInventoryItemsToBeSent); | |||
if (killAfterCompletion) | |||
if( | |||
llDie(); | llDie(); | ||
} | } | ||
} | } | ||
</ | </source> |
Latest revision as of 09: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();
}
}