Difference between revisions of "User:PixelProphet Lane/Scripts"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
Gotta figure this Wiki stuff out first
{{LSL Header}}


[[User: PixelProphet Lane/Scripts#Fast List Prim Contents|Fast List Prim Contents]]
{{box|Fast List Prim Contents|
 
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.
 
It's easier and much faster to loop through the Inventory Item types, store the current type in a variable, and then loop through each item that is an item of our currently stored type. This way you don't need to fetch the Inventory Item type for each item you find.
 
<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 leave the comments above as they are.
// In case you distribute this code as non modifiable part of your scripts, please include a reference to this page.
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>
}}

Revision as of 13:52, 2 April 2010