My first free script, also available on the SL Marketplace.
The purpose of it is to give contents of the object, excluding this script, to a person who clicks it. It doesn’t check for any permissions or ownership, just anyone who clicks it.
Please be aware that per LL restrictions, this will not give no copy items, nor will it be able to bypass the permissions system to give items the owner cannot transfer.
I have commented it and hope that they make sense! Similar versions are below, with different ways of handling things.
default
{
// When you click me…
touch_start(integer num_detected)
{
// I make a list
list InventoryList;
// Then I set up a way to count the contents of the object…
integer count = llGetInventoryNumber(INVENTORY_ALL);
// and I'll need this later!
string ItemName;
while (count--)
{
// Now I am adding all of the items to the list, which also needs a counted total
ItemName = llGetInventoryName(INVENTORY_ALL, count);
// But wait! We don't want it to add this script to that list.
if (ItemName != llGetScriptName() )
// If you wanted to manually exclude anything else, you'd do so here.
InventoryList += ItemName;
}
// Give all the items in the list to the toucher, in a folder named as per this prim's name.
llGiveInventoryList(llDetectedKey(0), llGetObjectName(), InventoryList);
}
}
Additionally, here is a non-commented version using slightly different list tactics which will also check for if the person is wearing the same group tag as the group is set to.
default
{
touch_start(integer total_number)
{
integer i;
for (i=0;i<total_number;i++)
{
key id = llDetectedKey(0);
if(llSameGroup(llDetectedKey(i)))
{
key target = llDetectedKey(i);
list inv;
integer i;
integer max = llGetInventoryNumber(INVENTORY_ALL);
for (i=0; i<max; ++i)
{
if (llGetInventoryType(llGetInventoryName(INVENTORY_ALL, i)) != INVENTORY_SCRIPT)
{
inv += [llGetInventoryName(INVENTORY_ALL, i)];
}
}
llGiveInventoryList(target, llGetObjectName(), inv);
}
else
{
llInstantMessage(id, "Sorry, but your tag is not for the right group. Please correct and try again!");
}
}
}
}
And a version which does no checks at all, but will give a landmark on click.
You may change this by editing INVENTORY_LANDMARK to other types, such as INVENTORY_OBJECT.
Note that if you try to do INVENTORY_SCRIPT, it will also give the script as it is not excluded!
default
{
touch_start(integer total_number)
{
// get the UUID of the person touching this object
key user = llDetectedKey(0);
// Give them the first landmark found in the object's contents
llGiveInventory(user, llGetInventoryName(INVENTORY_LANDMARK, 0) );
}
}
A version which gives you a paged menu to select items from, please read the third comment thoroughly and change accordingly.
// The message at the top of the blue menu string message = "Select Object to Take!";
// Can only the owner take items? integer OWNER_ONLY = FALSE;
// What kind of objects are being given? Choose such as INVENTORY_LANDMARK, INVENTORY_OBJECT, INVENTORY_SOUND, INVENTORY_TEXTURE, INVENTORY_NOTECARD, INVENTORY_ALL (will also serve this script, not advised, same with inventory script!!) integer INVENTORY_TYPE = INVENTORY_OBJECT;
// LL Dialog (blue menus) require us to converse over a channel integer channel = -1;
// Checking what type you specified above and how many there is, adding to list named objects! list getInventoryList(integer type){ list objects = []; integer i = 0; for(i = 0; i < llGetInventoryNumber(type); ++i){ objects += llGetInventoryName(type, i); } return objects; } dialog(key id, integer channel){ list objects = getInventoryList(INVENTORY_TYPE); llDialog(id, message, objects, channel); } default { // A failsafe in case anything has gone wonky… on_rez(integer param){ llResetScript(); } // We're starting up and picking a random channel then listening on it. state_entry(){ channel = (integer)llFrand(9999999); llListen(channel, "", "", ""); } // When you touch me… touch_start(integer num){ // I check if only owner is set, and appropriately give or don't give a menu to my clicker if((OWNER_ONLY && llDetectedKey(0) == llGetOwner()) || !OWNER_ONLY){ dialog(llDetectedKey(0), channel); } } // If you choose an item from the menu, it gives it to you! listen(integer channel, string name, key id, string message){ list objects = getInventoryList(INVENTORY_TYPE); if(llListFindList(objects, [message]) != -1){ llGiveInventory(id, message); } } }
Through a combination of these tested and partially commented scripts, I hope you will find what you need or be able to combine them to create it.
As much as I am happy to put my scripts, explanations, blogposts, and tutorials out there, I may not always be able to provide support for this free content and highly recommend looking into inworld help groups such as the lovely community at Builder’s Brewery.