|
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
|
12-29-2008 19:24
if( llGetInventoryPermMask(tmpitem, MASK_OWNER) & PERM_COPY )
This tells you if copy is enabled.
What if, tho, want to see if copy is *NOT* enabled.
I know more wordy ways of doing it,and that's what I use, but is there a direct syntax for & NOT PERM_COPY?
None of the wikis appear to cover that.
_____________________
Thread attempting to compile a list of which animations are freebies, and which are not: http://forums.secondlife.com/showthread.php?t=265609
|
|
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
|
12-29-2008 19:28
I'll let someone chime in on this, but I believe you use the tilde...
if(~llGetInventoryPermMask(tmpitem, MASK_OWNER) & PERM_COPY )
|
|
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
|
12-29-2008 19:37
true "~" turns all "1" of that integer bitfield into "0" and the other way around, asd it is the NOT operator.
|
|
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
|
12-29-2008 20:46
Many thanks. I'll add to offiicial wiki.
_____________________
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
|
12-29-2008 21:14
Or there's always:
if (llGetInventoryPermMask(tmpitem, MASK_OWNER) & PERM_COPY == 0)
|
|
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
|
12-30-2008 04:14
From: Ollj Oh true "~" turns all "1" of that integer bitfield into "0" and the other way around, asd it is the NOT operator. I beg to differ on your terminology "!" is the not operator and 1becomes 0, 0 becomes 1. "~" is the 1's Compliment operator where a -1 becomes 0 and 0 becomes -1. Your code will work, it is just the terminology I question.
|
|
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
|
12-30-2008 04:42
From: Ollj Oh true "~" turns all "1" of that integer bitfield into "0" and the other way around, asd it is the NOT operator. I beg to differ on your terminology "!" is the NOT operator as 1 becomes 0, 0 becomes 1. "~" is the 1's Compliment operator where a -1 becomes 0 and 0 becomes -1. test code: default { state_entry() { llListen(0,"","",""); } touch_start(integer total_number) { integer x; llOwnerSay("with ~ "+(string)(x = 0)+" becomes "+(string)~x); llOwnerSay("with ~ "+(string)(x = 1)+" becomes "+(string)~x); llOwnerSay("with ~ "+(string)(x = -1)+" becomes "+(string)~x); llOwnerSay("with ~ "+(string)(x = -2)+" becomes "+(string)~x); llOwnerSay("with ! "+(string)(x = 0)+" becomes "+(string)!x); llOwnerSay("with ! "+(string)(x = 1)+" becomes "+(string)!x); llOwnerSay("with ! "+(string)(x = -1)+" becomes "+(string)!x); llOwnerSay("with ! "+(string)(x = -2)+" becomes "+(string)!x); } }
result: new: with ~ 0 becomes -1 new: with ~ 1 becomes -2 new: with ~ -1 becomes 0 new: with ~ -2 becomes 1 new: with ! 0 becomes 1 new: with ! 1 becomes 0 new: with ! -1 becomes 0 new: with ! -2 becomes 0 As LSL treats any non zero value as TRUE and ~1 returns -2 then both 1 and -2 are TRUE therefore"~" is not equivalent to a NOT operator, whilst !-2 returns 0 so "!" is a valid NOT operator in all cases. Your code will work in this instance, it is just the terminology I question. The Correct answer would be if( ! llGetInventoryPermMask(tmpitem, MASK_OWNER) & PERM_COPY )
|
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
12-30-2008 10:03
From: Very Keynes The Correct answer would be
if( ! llGetInventoryPermMask(tmpitem, MASK_OWNER) & PERM_COPY )
No, this really isn't the correct answer. The correct answer IS to use the bitwise tilde operator not the boolean not operator. Edit(added): This is owing to operator precedence. In your solution, I think that you think you are saying: if ( !(llGetInventoryPermMask(tmpitem, MASK_OWNER) & PERM_COPY))... when you are actually saying: if ( !(llGetInventoryPermMask(tmpitem, MASK_OWNER)) & PERM_COPY)...
_____________________
http://slurl.com/secondlife/Together
|
|
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
|
12-30-2008 10:38
OOps, Correct, I left out the Brackets. The point I was actual trying to make is that ~ is not equivalent to NOT, but my final example rather defeated it *blush*
|