Tree Item Metadata does not work with color black.

Godot Version

4.2.2.stable

Question

Heyo I cant seem to use the color black when its put into Treeitem metadata.

func _on_list_item_selected():
	var t = Colors_List.get_selected().get_metadata(0) #Will equal black
	
	if Colors_List.get_selected().get_metadata(0): #Will not pass if black
		CurrentColor = Colors_List.get_selected().get_metadata(0)
		CurColor_Box.color = CurrentColor
		Slider_R.value = CurrentColor.r
		Slider_G.value = CurrentColor.g
		Slider_B.value = CurrentColor.b
		Label_Update()

When this function is run, t always gets the color from the metadata even when its black but the if condition does not pass when the color is black. every other colors it works fine.

The if condition exists incase the root item is selected, it holds no metadata.

All metadata is constructed the same way:

func Populate_List():
	
	Colors_List.clear()
	var List_Root = Colors_List.create_item()
	List_Root.set_text(0, "Stored: " )
	
	for c in StoredColors:
		var t = Colors_List.create_item(List_Root)
		t.set_text(0, c.Name)
		t.set_metadata(0, c.color)

and all data is made the same way in a simple classfile that only stores a string and color.


func DefaultColors():
	StoredColors.append( Class_MapPlanner_Color.new( "Stairs" , Color( 0.8 , 0.8 , 0.8 , 1 ) ) )
	StoredColors.append( Class_MapPlanner_Color.new( "Window" , Color( 0.2 , 0.7 , 1 , 1 ) ) )
	StoredColors.append( Class_MapPlanner_Color.new( "Void" , Color( 0 , 0 , 0 , 1 ) ) ) #<- Problem
	StoredColors.append( Class_MapPlanner_Color.new( "Outdoors" , Color( 0.25 , 0.8 , 0 , 1 ) ) )

Would != null work?

if Colors_List.get_selected().get_metadata(0) != null:
# or
if t != null

Yes that works, wondering if anyone knew why or if i should make a GitHub bug report.

I think it’s intentional that Black is a falsy value. I personally do not like implicit boolean conversions, but it seems popular.