llGetInventoryPermMask

From Second Life Wiki
Revision as of 21:48, 2 October 2007 by Ppaatt Lynagh (talk | contribs) (add first example - promptly complain any time the SL GUI restricts copying differently than you wish)
Jump to navigation Jump to search

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

Promptly complain any time the SL GUI restricts copying differently than you wish.

// Remember the last perms described.

integer everyonePerms;
integer nextPerms;
integer troubles;

fetchPerms()
{
    everyonePerms = llGetInventoryPermMask(llGetScriptName(), MASK_EVERYONE);
    nextPerms = llGetInventoryPermMask(llGetScriptName(), MASK_NEXT);
}

// Describe the copyable thing for which some clients respect the perms.

string me()
{
    return llGetScriptName();
}

// Describe the perms.

permsShouldBe()
{
        integer wasTroubles = troubles;
        troubles = 0;
        
        if (!(everyonePerms & PERM_COPY))
        {
            llOwnerSay("No = Allow anyone to copy " + me());
            troubles += 1;
        }
        
        if (!(nextPerms & PERM_MODIFY))
        {
            llOwnerSay("No = Next owner can modify " + me());
            troubles += 1;
        }
        if (!(nextPerms & PERM_COPY))
        {
            llOwnerSay("No = Next owner can copy " + me());
            troubles += 1;
        }
        if (!(nextPerms & PERM_TRANSFER))
        {
            llOwnerSay("No = Next owner can resell/ give away " + me());
            troubles += 1;
        }
        
        if (wasTroubles && !troubles)
        {
            llOwnerSay("Open / Yes Mod/ Yes Copy/ Yes Transfer");
        }
        
        if (wasTroubles || troubles)
        {
            llOwnerSay("");
        }
}

// Describe the perms when rezzed or reset, and when the perms change.

default
{
    on_rez(integer start_param)
    {
        llResetScript(); 
    }
    state_entry()
    {
        fetchPerms();
        permsShouldBe();
        llSetTimerEvent(1.0); // 1.0 = once per second
    }
    timer()
    {
        integer wasEveryonePerms = everyonePerms;        
        integer wasNextPerms = nextPerms;        
        fetchPerms();
        if (everyonePerms != wasEveryonePerms)
        {
            permsShouldBe();
        }
        else if (nextPerms != wasNextPerms)
        {
            permsShouldBe();
        }
    }
}

Deep Notes

Search JIRA for related Issues

Signature

function integer llGetInventoryPermMask( string item, integer mask );