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();
    }
}