They are a bit on the 'hardcore' part of coding, but they are very simple if you take a little time to understand them.

Just remembering old concepts:
All values in computers are based on bits (binary), so an 8-bit number is a row of 8 bits. To convert a row of bits to a decimal 'integer', you assign values to each bit. In 8-bit numbers (which can hold an integer from 0 to 256) the values are:

128 64 32 16 8 4 2 1

So there are some numbers (X are 'on' bits, 0 are 'off'):

0 0 0 0 x 0 x 0 = 8+2 = 10

x 0 0 x 0 x 0 x = 128+16+4+1 = 149

0 0 x 0 x 0 0 0 = 32+8 = 40;

So you can see that each number from 0 to 256 is a unique combination of eight ON and OFF bits.


Actually 3DGS makes transparent use of this in its code. For instance if you code:
move_mode = ignore_passable + ignore_me + ignore_sprites;

You are actually adding ON bits to move_mode. If you debug (watch) the values for these flags, you will find that ignore_passable = 4, and others are 1, 2, 8, 16, 32 etc.

Actually it's not 'correct' to use + instead of |.
the | operator is like an add for bitwise values, but it only works once.

For instance:
move_mode = ignore_passable + ignore_me + ignore_passable;

will add '4' twice, actually adding '8', which is another flag. ignore_passable would, in this case, be OFF.

move_mode = ignore_passable | ignore_me | ignore_passable;

this is the same as:
move_mode = ignore_passable | ignore_me;

because a value can't be 'added' twice using |.


The best training for this is to debug or watch certain values in the debugger, or display them on screen. For instance:

x = 128 | 2 ; //x is now '130'

x = 130 | 2 ; //x is still '130'

x = 130 ^ 2; //x is now '128'

x = 128 ^ 2; //x is still '128'.


Last thing: for 16-bit numbers, you just have continue duplicating the values for the bits. So the next 8 'flags' values would be:
256
512
1024
2048
4096
8192
16384
32768
65536

I am not sure how long is a 3dgs value, since it's a generic VAR for holding integers and floats etc. From the values vars can hold, i'd guess they are 32-bits long. But somehow I belive that you should limit to 16-bits (16 'flags' per value).