• Winking Gwyn
  • Categories

  • Feeling generous today? Any money received will support the continued web hosting of this blog. Donate towards my web hosting bill!
  • Creative Commons License
  • Gwyneth Llewelyn is offline in Second Life.
  • Pages

  • Meta

  • Blog Rank: 34,363
02 Mar

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

Leave a Reply

Login Method

OpenID

Anonymous

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2008 Gwyn’s Home | Entries (RSS) and Comments (RSS)

Powered by Wordpress, design by Web4 Sudoku, based on Pinkline by GPS Gazette