|
Altern8 McMillan
Registered User
Join date: 27 Mar 2007
Posts: 36
|
08-18-2007 07:16
Hi there, I'm struggling a bit right now with bitwise operators. I do understand e.g. how to figure out if a permission is set, but how do I check if a permission is not set?? Example: integer perm_mask = llGetObjectPermMask( MASK_NEXT); if(perm_mask & PERM_COPY) llSay(0,"The next owner will have copy permissions.");
Well there is nothing like perm_mask &! PERM_COPY of course, and I cannot do a ~ on it either. ??? thx and greetz A8
|
|
Altern8 McMillan
Registered User
Join date: 27 Mar 2007
Posts: 36
|
08-18-2007 07:35
I figured it out myself  Love those situations, just if someone wants to know it: integer perm_mask = llGetObjectPermMask( MASK_NEXT); if((perm & PERM_COPY) != PERM_COPY) llSay(0,"The next owner will have no copy permissions.");
|
|
10KHz Tone
Registered User
Join date: 13 Mar 2007
Posts: 3
|
08-22-2007 03:09
From: Altern8 McMillan Hi there, I'm struggling a bit right now with bitwise operators. I do understand e.g. how to figure out if a permission is set, but how do I check if a permission is not set?? Example: integer perm_mask = llGetObjectPermMask( MASK_NEXT); if(perm_mask & PERM_COPY) llSay(0,"The next owner will have copy permissions.");
Well there is nothing like perm_mask &! PERM_COPY of course, and I cannot do a ~ on it either. ??? thx and greetz A8 Sure there is. You gave the simplest answer already. I've tested it and used it before and it works well: integer perm_mask = llGetObjectPermMask(MASK_NEXT); if(~perm_mask & PERM_COPY) llSay(0, "Sorry, no copy perms for the next owner!"  ; What happens is the permissions mask gets bitwise inverted, then you apply the AND mask which will now pull out FALSE permissions. You can also squash it all into one if statement which saves a few bytes... if (~llGetObjectPermMask(MASK_NEXT) & PERM_COPY) llSay (0, "Sorry, no copy perms for the next owner!"  ; this can be used to advantage sometimes... if (~llGetObjectPermMask(MASK_NEXT) & (PERM_COPY | PERM_TRANSFER)) llSay (0, "The next owner has some rights restricted."  ; This will be true if the next owner either cannot transfer, or cannot copy (or both). If the next owner can copy AND transfer, the condition will not be true.
|