Difference between revisions of "Unpacker On Rez (NewAge)"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) m (some minor improvements) |
m (<lsl> tag to <source>) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 3: | Line 3: | ||
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 | // 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 | ||
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; | ||
killAfterCompletion = TRUE; | |||
// use INVENTORY_ALL to not apply a filter | |||
addThisScriptToFolder = FALSE; | |||
killAfterCompletion = TRUE; | |||
} | } | ||
Line 31: | Line 25: | ||
{ | { | ||
integer numberOfItems = llGetInventoryNumber(inputType); | integer numberOfItems = llGetInventoryNumber(inputType); | ||
string thisScript = llGetScriptName(); | |||
string itemName; | |||
list listOfItemsToSend; | |||
integer index; | |||
integer | |||
do | do | ||
{ | { | ||
itemName = llGetInventoryName(inputType, | itemName = llGetInventoryName(inputType, index); | ||
if(itemName != "") | if(itemName != "") | ||
Line 50: | Line 43: | ||
} | } | ||
} | } | ||
while(++ | while(++index < numberOfItems); | ||
// change to number of items in list now | // change to number of items in list now | ||
Line 57: | Line 50: | ||
if(numberOfItems) | if(numberOfItems) | ||
{ | { | ||
llGiveInventoryList(inputKey, | llGiveInventoryList(inputKey, nameOfFolderToBeCreated, listOfItemsToSend); | ||
llInstantMessage(inputKey, | llInstantMessage(inputKey, | ||
"/me [" + thisScript + "]: Items have been sent into a folder named '" | "/me [" + thisScript + "]: Items have been sent into a folder named '" | ||
Line 71: | Line 64: | ||
on_rez(integer start_param) | on_rez(integer start_param) | ||
{ | { | ||
init(); | |||
key owner = llGetOwner(); | key owner = llGetOwner(); | ||
Line 82: | Line 77: | ||
} | } | ||
} | } | ||
</ | </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();
}
}