I beleive you could use bit operations to acheive what you are trying to do, because the bits in the collision layer and collision mask are used to resolve collisions. For example:
#shift the 1 (which is currently on the 1st bit) to be in the desired position (7 or 4)
var bit7Mask = 1 << 6 #i think its 6 (7 -1), because the 1 (0000 0001) is already in 1st bit's position
var bit4Mask = 1 << 3
#bit7Mask = (0100 0000)
#bit4Mask = (0000 1000)
Now that you have define the mask, you can use it in your if statement conditions by comparing the mask to the collision layer of your body using the bit-wise and operator &. The below code should do the trick, if I