How do I properly set the value of a light2D's "Item Cull Mask" and an object's "Light Mask" value in gdscript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KnightNine

I want to know if I’m setting these values correctly…
I Have a row of cards with sprite nodes within them that are larger than the card itself so i added “Light Only” materials to these sprites to only reveal them within the border of the card using a light2D node in the shape of that card.

I set the light mask & item cull mask values of these card scenes’ Sprite and light2D with this function so that they don’t interact with each other:

func ChangeLightLayer(layerIndex):
    portrait.light_mask = layerIndex
    portraitLight.light_mask =layerIndex
    portraitLight.range_item_cull_mask = layerIndex

But the light2D nodes still reveal the other cards’ images despite being set to different values.
In the editor it seems to work fine with these “boxes” that you select / highlight to specify the Light Mask value(s), but my function doesn’t seem to have the same effect.

I see that hovering over these boxes shows that they have a “Bit” and “value” values rather than a singular value, the “value” value also seems to iterate exponentially “1,2,4,8,16…” which is foreign to me. I’ll try setting my layerIndex to these values using this function:

func GetIteration(repeat):
    var value = 1
    while (repeat>0):
	    value*=2
	    repeat-=1
	
    return value

And it seems to have worked but should I be doing this?