By default, every projectile and collider has a collision mask of 1. If bit.band([projectile mask], [collider mask]) ~= 0, then the projectile will collide with that collider. Otherwise, it won't; the projectile will pass through.
So most projectiles will collide with most projectile colliders, since bit.band(1, 1) is equal to 1, not 0. If you set a projectile's collision mask to 0, it won't collide with
any projectile colliders, since bit.band(0, anything) is equal to 0. Note that it will still collide with solid tiles.
If you want a projectile that only collides with a few colliders, you could set its collision mask to 2, and set the collision group to 2 for the colliders you want it to collide with; bit.band(1, 2) is 0, but bit.band(2, 2) is not. Or if you want that collider to collide with default projectiles too, make its collision group 3, since bit.band(1, 3) and bit.band(2, 3) are both nonzero.
The only example of this in the asset pack is the fire rune trap. It has a projectile collider with a collision group of 2, so almost everything passes through it, but the dispel projectile has a collision mask of 3, so it hits rune traps.
If you're working with a large number of collision bits, you probably want to enter them as hexadecimal constants (prefix with 0x) rather than decimal ones. So use
0x14 instead of
20, for example; it's much easier to tell which bits are present that way. Unfortunately, Lua does not let you enter binary constants like some languages, just decimal and hexadecimal. Also, because of how the bit library works*, avoid using numbers greater than 0x7fffffff or lower than -0x8000000.
akroma222 wrote:3. Can we define our own Collision Groups ?
No. Do you need more than 32 collision groups?
*I've been typing out bit.band() every time instead of just saying "AND" because it's not a real bitwise AND; numbers in Grimrock are all double precision floating point, so the real AND of 1 and 3 would actually be 0. This would be a pain in the butt to work with, so instead, the bit library basically converts the numbers to 32-bit integers and back. That's why you get unwanted results if you try to use numbers outside the 32-bit integer range.