I found this code on the scripting website
m |= (1<<layers[l]);
I have no idea what |= or << mean.
I found this code on the scripting website
m |= (1<<layers[l]);
I have no idea what |= or << mean.
Or-equals and bitshift left.
Or-equals sets a vale to the OR of it and another value; which returns a value with all bits set that are set in either A or B.
that is, 0101 OR 1010 == 1111; 0101 OR 0111 == 0111; 0000 OR 0001 == 0001
Bitshifts move bits in an integer.
The integer 1 is represented by the bits 00000001; bitshifting that left by (e.g. 5) produces 00100000.
so that line is saying
m = m OR ( 1 bitshifted left layers[l] times );
What the line actually does is add another layer to the mask M. To determine if a layer is IN m, you would write
if ( layer m ) {
// layer is in m
}