Page 1 of 1

&, &!, &=

Posted: Fri Jan 27, 2012 5:33 pm
by Concept
I was having some trouble figuring out what these did and after some detective work and help from FF I solved them. I was requested to make this thread explaining them so here it is:

& checks the first variable's bit values against the second variable's bit values
In the editor hit up the misc button and head over to the calc tab, there is a bit calculation page there. Here you can combine various powers of 2 to create numbers. Basically what & does is, check to see if any of the powers of 2 that make up the first variable also exist in the second variable.
The number 100 for example is made up of 4, 32, and 64
The number 12 is made up of 8 and 4
If you do 100 & 12, you'll get true because there is a 4 in both of them

&! does the opposite of &

&= does something very similar, except it checks to see if ALL the powers of 2 that make up that number are also in the other number so for example 100 &= 12 would be false because 8 isn't in 100 but 100&=36 would be true because 36 is 4 and 32, both of which are in 100.

This is actually pretty exciting stuff, here is why: due to the way it works, you can now reuse the same variable for many things, for example say you had a variable that checked to see if part A was destroyed and a variable that changed when Part B was destroyed. So say you have the following events:
Event 1:
Condition: Part A destroyed
Action: Variable 1 + 2
Event 2:
Condition: Part A destroyed
Action: Variable 1 + 4

Using the same variable you can check for all 4 states:
1.) Part a destroyed and part b destroyed (Variable 1 &= 6)
2.) Part a destroyed and part b alive (Variable 1 & 2)
3.) Part b destroyed and part a alive (Variable 1 & 4)
4.) Part a alive and part b alive (Variable 1 = 0 ) 8D
Also SECRET BONUS state:
X.) Part a OR part b dead (Variable 1 & 6)


There are a lot of other applications too but those are up to you to discover ( I AM TOO LAZY TO KEEP WRITING).

Re: &, &!, &=

Posted: Sat Jan 28, 2012 5:40 pm
by Kamui OS
Hmmm..... so the matter is much more complex than I had originally thought...

http://wiki.fraxy.net/index.php?title=T ... ify_Status" onclick="window.open(this.href);return false;