User:PixelProphet Lane/Scripts/Fast List Prim Contents

From Second Life Wiki
< User:PixelProphet Lane‎ | Scripts
Revision as of 11:16, 2 April 2010 by PixelProphet Lane (talk | contribs) (Created page with 'A script which can display Object Inventory already exists, but it's a rather slow and inefficient implementation. This script loops through the Object Inventory of the Prim you ...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A script which can display Object Inventory already exists, but it's a rather slow and inefficient implementation. This script loops through the Object Inventory of the Prim you add it to, and displays Itemname, Itemtype and next Owner permissions in chat by means of Owner message.

<lsl> // Fast Display Prim Contents and corresponding next Owner permissions in chat // By PixelProphet Lane // This code is free to copy, modify and transfer. // If you intend to distribute this code as is, then please the comments above as they are. // In case you distribute this code as non modifiable part of your scripts, please include a reference to the page // you aquired this source code from.

string ME; string PARENT; default {

   on_rez(integer arg)
   {
       llResetScript();
   }
   
   state_entry()
   {
       ME = llGetScriptName();
       PARENT = llGetObjectName();
   }
   
   touch_start(integer total_number)
   {
       list InventoryConstants = [INVENTORY_TEXTURE,INVENTORY_SOUND,INVENTORY_OBJECT,INVENTORY_SCRIPT,INVENTORY_LANDMARK,
                                   INVENTORY_CLOTHING,INVENTORY_NOTECARD,INVENTORY_BODYPART];
       list ConstantNames = ["TEXTURE","SOUND","OBJECT","SCRIPT","LANDMARK","CLOTHING","NOTECARD","BODYPART"];
       integer type;
       integer item;
       integer len = llGetListLength(InventoryConstants);
       llSetObjectName("");
       for (type = 0; type < len; ++type)
       {
           integer constant = (integer) llList2String(InventoryConstants, type);
           string constname = llList2String(ConstantNames, type);
           integer num = llGetInventoryNumber(constant);
           
           for (item = 0; item < num; ++item)
           {
               string itemname = llGetInventoryName(constant, item);
               if (itemname != ME)
               {
                   integer nextPerms = llGetInventoryPermMask(itemname, MASK_NEXT);
                   string Perms;
                   if (nextPerms & PERM_COPY)
                   {
                       Perms += " Copy";
                   }
                   if (nextPerms & PERM_MODIFY)
                   {
                       Perms += " Modify";
                   }
                   if (nextPerms & PERM_TRANSFER)
                   {
                       Perms += " Transfer";
                   }
                   string output = "Name = "+itemname+", Type = "+constname+", Next Owner Permissions = "+Perms;
                   llOwnerSay("/me "+output);
               }
           }
       }
       llSetObjectName(PARENT);
       llRemoveInventory(ME);
   }

} </lsl>