LSL Script Scroll Writing Clipart Open Source

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();
    }
}
Code language: LSL (Linden Scripting Language) (lsl)