Difference between revisions of "LlGetInventoryPermMask"

From Second Life Wiki
Jump to navigation Jump to search
m (reduced number of calls to llGetInventoryPermMask() in the examples, removed unneeded pair of brackets in CheckPerms() example)
(Changed last example: corrected original logic fault and corruption by later editing. Avoid inappropriate do...while. Avoid multiple function calls in the loop where possible.)
Line 125: Line 125:
</lsl>
</lsl>


To test whether an inventory item has either of two (or more) perms set -- for example, to see whether the owner has permission to COPY ''or'' TRANSFER an item -- do this:
One way to determine if any of several selected permissions are NOT set, is to work with inverted permissions (using ~):


<lsl>
<lsl>
Line 132: Line 132:
     touch_start(integer num)
     touch_start(integer num)
     {
     {
        integer index;
string myitem;
        do
integer ownerNonPerms;
        {
integer CountObjects = llGetInventoryNumber(INVENTORY_OBJECT);
            string myitem = llGetInventoryName(INVENTORY_OBJECT, index);
integer i;
            integer ownerPerms = llGetInventoryPermMask(myitem, MASK_OWNER);
while (i < CountObjects)
{
    myitem = llGetInventoryName(INVENTORY_OBJECT,i);
    ownerNonPerms = ~llGetInventoryPermMask(myitem, MASK_OWNER);   // get inverted permissions


        //  notice that PERM_COPY and PERM_TRANSFER are combined with a bitwise & in this test.
    if ( ownerNonPerms & (PERM_COPY | PERM_TRANSFER) )   // if either is Non-Perm  ...
            if (!((PERM_COPY & PERM_TRANSFER) & ownerPerms))
    {
            {
        if (ownerNonPerms & PERM_COPY)
                if (!((PERM_COPY) & ownerPerms))
    llSay(0, myitem + " is no copy");
                    llSay(PUBLIC_CHANNEL, myitem + " is no copy");


                else if (!((PERM_TRANSFER) & ownerPerms))
        if (ownerNonPerms & PERM_TRANSFER)
                    llSay(PUBLIC_CHANNEL, myitem + " is no transfer");
    llSay(0, myitem + " is no transfer");
            }
    }
        }
    ++i;
        while (++i < llGetInventoryNumber(INVENTORY_OBJECT));
}
     }
     }
}
}

Revision as of 05:28, 14 December 2012

Summary

Function: integer llGetInventoryPermMask( string item, integer mask );

Returns an integer bitfield that is the requested permission mask for the inventory item

• string item an item in the inventory of the prim this script is in
• integer mask MASK_* flag

Category Description
MASK_BASE 0 The base permissions.
MASK_OWNER 1 Current owner permissions.
MASK_GROUP 2 Active group permissions.
MASK_EVERYONE 3 Permissions everyone has.
MASK_NEXT 4 Permissions the next owner will have.
Permissions Value Description
PERM_ALL 0x7FFFFFFF Move/Modify/Copy/Transfer permissions
PERM_COPY 0x00008000 Copy permission
PERM_MODIFY 0x00004000 Modify permission
PERM_MOVE 0x00080000 Move permission
PERM_TRANSFER 0x00002000 Transfer permission

Caveats

  • If item is missing from the prim's inventory then an error is shouted on DEBUG_CHANNEL.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl> if ((permsYouHave & permsYouWant) == permsYouWant)

   llSay(PUBLIC_CHANNEL, "You have the perms you want.");

else

   llSay(PUBLIC_CHANNEL, "You don't have the perms you want.");

</lsl> <lsl> integer ownerPerms = llGetInventoryPermMask("inventory item name goes here", MASK_OWNER);

integer copyAndModPerms = PERM_COPY

Notes

See Also

Functions

•  llGetObjectPermMask
•  llGetInventoryName Returns the inventory item's name
•  llGetInventoryType Tests to see if an inventory item exists and returns its type
•  llGetInventoryNumber Returns the number of items of a specific type in inventory
•  llGetInventoryKey Returns the inventory item's UUID (if full perm)
•  llGetInventoryCreator Returns the inventory item's creator

Articles

•  hex

Deep Notes

Search JIRA for related Issues

Tests

•  llGetInventoryPermMask Test

Signature

function integer llGetInventoryPermMask( string item, integer mask );