Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

understanding mask owner

Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
04-06-2009 19:50
Wiki says MASK_OWNER shows current owner permissions: http://wiki.secondlife.com/wiki/LlGetObjectPermMask

Running a script in a box in which I have (A) items that i can't copy (they are non-copiable for me, made by somebody else) and (B) some prims I have just made, leaving next-owner perms as no copy -- but these prims are still copiable in my hands, of course.

I want to make a list of only the ones that are non-copiable for me. That would be Group A above.

My expection was that the filter:

(~PERM_COPY & llGetInventoryPermMask(myitem,MASK_OWNER) )
would pick the Group A ones up, and ignore the Group B ones.

But it doesn't ignore the Group B ones; it adds them in, even though my owner permissions on them are copy.

I must be doing something wrong; bleary eyes I guess. Can anyone spot what I'm doing wrong?

integer i;
integer type = INVENTORY_ALL;
list non-copiables = [];
string myitem;
n = llGetInventoryNumber(type);
for (i = 0; i < n; ++i) {
myitem = llGetInventoryName(type, i);
if (~PERM_COPY & llGetInventoryPermMask(myitem, MASK_OWNER) ) {
llSay(0, "adding to non-copiables " + myitem);
non-copiables = non-copiables + [myitem];
}
}
_____________________
Thread attempting to compile a list of which animations are freebies, and which are not:

http://forums.secondlife.com/showthread.php?t=265609
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
04-07-2009 06:45
Dodged the problem by going for the copiable ones, and then assuming what was left was non-copiable.
_____________________
Thread attempting to compile a list of which animations are freebies, and which are not:

http://forums.secondlife.com/showthread.php?t=265609
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-07-2009 07:20
~ was not the operator you were looking for... ! is

(!(PERM_COPY & llGetInventoryPermMask( myitem, MASK_OWNER )))

you could probably get away with

(PERM_COPY & (!llGetInventoryPermMask( myitem, MASK_OWNER )))
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
! or ~ with permissions mask?
04-07-2009 07:36
I'm very confused whether it is ! or ~ . See this thread:

/54/fc/300034/1.html

In that thread, the method suggested by Hewee Zetkin would seem to be the easiest to keep clear in one's mind, I suppose:

if (llGetInventoryPermMask(tmpitem, MASK_OWNER) & PERM_COPY == 0)
_____________________
Thread attempting to compile a list of which animations are freebies, and which are not:

http://forums.secondlife.com/showthread.php?t=265609
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-07-2009 08:50
From: Void Singer
(PERM_COPY & (!llGetInventoryPermMask( myitem, MASK_OWNER )))

Right. Minor typo though. '!' is boolean. '~' is bitwise. This would work:

(PERM_COPY & ~llGetInventoryPermMask(myitem, MASK_OWNER))

But yes, it is even a little clearer/more explicit to throw a zero comparison in there, since the result of bitwise operations CONCEPTUALLY is an integer, not a boolean. So one of:

((PERM_COPY & ~llGetInventoryPermMask(myitem, MASK_OWNER)) != 0)
((PERM_COPY & llGetInventoryPermMask(myitem, MASK_OWNER)) == 0)

would be about the clearest, least ambiguous, test to perform. I'd generally prefer the latter. Double negatives can get confusing sometimes. :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-07-2009 09:32
doh, heewee is of course right, and I need caffeine.

you just reversed the wrong bitmask.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -