Difference between revisions of "Unpacker On Touch (NewAge)"
Jump to navigation
Jump to search
(Created page with ''''Unpacker On Touch''' Version 1.0 Just Copy and Paste into the object that contains your product and configure the script to your needs! New Motto: Save and Sell! <lsl> ////...') |
m (<lsl> tag to <source>) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
'''Unpacker On Touch''' | '''Unpacker On Touch''' | ||
Just Copy and Paste into the object that contains your product and configure the script to your needs! | Just Copy and Paste into the object that contains your product and configure the script to your needs! | ||
Line 6: | Line 5: | ||
New Motto: Save and Sell! | New Motto: Save and Sell! | ||
< | <source lang="lsl2"> | ||
// NewAge Unpacker On Touch Script | // NewAge Unpacker On Touch 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) | ||
{ | { | ||
llResetScript(); | llResetScript(); | ||
} | } | ||
touch_start(integer num_detected) | |||
{ | { | ||
key owner = llGetOwner(); | |||
key id = llDetectedKey(0); | |||
// if not the owner touching, abort process | |||
if (id != owner) | |||
return; | |||
if (messageToSendUponRez != "") | |||
llInstantMessage(owner, messageToSendUponRez); | |||
try_to_send_items(owner, typeOfInventoryItemsToBeSent); | |||
if (killAfterCompletion) | |||
llDie(); | |||
} | } | ||
} | } | ||
</ | </source> |
Latest revision as of 09:15, 25 January 2015
Unpacker On Touch
Just Copy and Paste into the object that contains your product and configure the script to your needs!
New Motto: Save and Sell!
// NewAge Unpacker On Touch 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)
{
llResetScript();
}
touch_start(integer num_detected)
{
key owner = llGetOwner();
key id = llDetectedKey(0);
// if not the owner touching, abort process
if (id != owner)
return;
if (messageToSendUponRez != "")
llInstantMessage(owner, messageToSendUponRez);
try_to_send_items(owner, typeOfInventoryItemsToBeSent);
if (killAfterCompletion)
llDie();
}
}