Difference between revisions of "Unpacker On Rez (NewAge)"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) m (some minor improvements) |
|||
Line 4: | Line 4: | ||
<lsl> | <lsl> | ||
// NewAge Auto Unpacker Script | // NewAge Auto Unpacker Script | ||
// By Asia Snowfall | // By Asia Snowfall | ||
string nameOfFolderToBeCreated; | |||
string messageToSendUponRez; | |||
integer addThisScriptToFolder; | |||
integer typeOfInventoryItemsToBeSent; | |||
integer killAfterCompletion; | |||
string | |||
init() | |||
{ | |||
// do not use an empty string | |||
nameOfFolderToBeCreated = llGetObjectName(); | |||
// leave empty to not send a message upon rez | |||
messageToSendUponRez = ""; | |||
// use INVENTORY_ALL to not apply a filter | |||
typeOfInventoryItemsToBeSent = INVENTORY_ALL; | |||
addThisScriptToFolder = FALSE; | |||
killAfterCompletion = TRUE; | |||
} | } | ||
try_to_send_items(key inputKey, integer inputType) | |||
{ | { | ||
integer | integer numberOfItems = llGetInventoryNumber(inputType); | ||
list | string thisScript = llGetScriptName(); | ||
string itemName; | |||
list listOfItemsToSend; | |||
integer i; | |||
do | do | ||
{ | { | ||
itemName = llGetInventoryName(inputType, i); | |||
if( | |||
if(itemName != "") | |||
{ | { | ||
if( | if(addThisScriptToFolder && itemName == thisScript) | ||
listOfItemsToSend += [itemName]; | |||
else if(itemName != thisScript) | |||
else if( | listOfItemsToSend += [itemName]; | ||
} | } | ||
}while( | } | ||
if( | while(++i < numberOfItems); | ||
// change to number of items in list now | |||
numberOfItems = llGetListLength(listOfItemsToSend); | |||
if(numberOfItems) | |||
{ | { | ||
llGiveInventoryList(inputKey, nameOfCreatedFolder, listOfItemsToSend); | |||
llGiveInventoryList( | llInstantMessage(inputKey, | ||
llInstantMessage( | "/me [" + thisScript + "]: Items have been sent into a folder named '" | ||
+ nameOfFolderToBeCreated + "' within your inventory."); | |||
} | } | ||
else | else | ||
llInstantMessage(inputKey, | |||
"/me [" + thisScript + "]: Could not find inventory items to send!"); | |||
llInstantMessage( | |||
} | } | ||
default | default | ||
{ | { | ||
on_rez(integer | on_rez(integer start_param) | ||
{ | { | ||
key owner = llGetOwner(); | |||
if( | if (messageToSendUponRez != "") | ||
llInstantMessage(owner, messageToSendUponRez); | |||
try_to_send_items(owner, typeOfInventoryItemsToBeSent); | |||
if (killAfterCompletion) | |||
if( | |||
llDie(); | llDie(); | ||
} | } | ||
} | } | ||
</lsl> | </lsl> |
Revision as of 11:14, 18 October 2012
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() { // do not use an empty string
nameOfFolderToBeCreated = llGetObjectName();
// leave empty to not send a message upon rez
messageToSendUponRez = "";
// use INVENTORY_ALL to not apply a filter
typeOfInventoryItemsToBeSent = INVENTORY_ALL;
addThisScriptToFolder = FALSE;
killAfterCompletion = TRUE;
}
try_to_send_items(key inputKey, integer inputType) {
integer numberOfItems = llGetInventoryNumber(inputType);
string thisScript = llGetScriptName(); string itemName; list listOfItemsToSend;
integer i; do { itemName = llGetInventoryName(inputType, i);
if(itemName != "") { if(addThisScriptToFolder && itemName == thisScript) listOfItemsToSend += [itemName];
else if(itemName != thisScript) listOfItemsToSend += [itemName]; } } while(++i < 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) { key owner = llGetOwner();
if (messageToSendUponRez != "") llInstantMessage(owner, messageToSendUponRez);
try_to_send_items(owner, typeOfInventoryItemsToBeSent);
if (killAfterCompletion) llDie(); }
} </lsl>