Simple Device To Give The Whole Inventory

You’ve guessed it — this is also part of my list of exercises for the LSL training courses.

This device gives all the inventory inside it in a folder, named as the object itself, and checks to avoid giving the script name instead. Dropping/removing further items inside the device will reset it to re-read the inventory again.

list objectList;
default
{
state_entry()
{
integer i;
integer totalObjects = llGetInventoryNumber(INVENTORY_ALL);
string tempName;
for (i = 0; i < totalObjects; i++)
{
tempName = llGetInventoryName(INVENTORY_ALL, i);
if (tempName != llGetScriptName())
objectList += [tempName];
}
}
touch_start(integer who)
{
integer i;
for (i = 0; i < who; i++)
llGiveInventoryList(llDetectedKey(i), llGetObjectName(), objectList);
}
changed(integer what)
{
if (what & CHANGED_INVENTORY)
llResetScript();
}
}

CC BY 4.0 Simple Device To Give The Whole Inventory by Gwyneth Llewelyn is licensed under a Creative Commons Attribution 4.0 International License.

About Gwyneth Llewelyn

I'm just a virtual girl in a virtual world...