Invalid call. Nonexistant function 'get_custom_data' in base 'Array'

Godot Version

4.2.2

Question

Hello, relative newbie, been working in godot for a few weeks now. I am getting the error in the title for a certain part of my script that works fine when used elsewhere. The apparently problematic part also works fine when I test it in a print statement prior, produces the expected result without error. For context, this code is part of some errorchecking for tile placement by the player in an isometric game. The specific code that is causing the error/crash seems to be :

current_dict[current_cell_coords][0].get_custom_data(is_fullblock) == true

Basically I have a dictionary, where the keys are Vector2is and the values are arrays containing tile data in index 0. I am attempting here to access it to get the custom data, and this has worked in other places, and putting just ‘current_dict[current_cell_coords][0].get_custom_data(is_fullblock)’ in a print statement returns true before then causing the crash when used in the if statement.

Full code for the function:

func errorcheck_complex(decider_ID: int, currentcell_highestlevel: TileMap, current_cell_coords: Vector2i, below_cell_coords: Vector2i) -> bool:
	var valid = true
	if decider_ID > 2:
		# if current cell contains a full block on the decider level and cell below has a fullblock on tilemap one whole level below
		if currentcell_highestlevel != null:
			var current_dict: Dictionary = match_tilemap_to_dict(currentcell_highestlevel)
			#print(current_dict)
			var dict_index: int = squarefootage_dicts.find(current_dict)
			var below_dict: Dictionary = squarefootage_dicts[dict_index-1]
			print("Current dict coords 0: ", current_dict[current_cell_coords][0])
			print("Fullblock: ", current_dict[current_cell_coords][0].get_custom_data(is_fullblock))
			if current_dict[current_cell_coords][0] != null && current_dict[current_cell_coords][0].get_custom_data(is_fullblock) == true\
			&& below_dict[below_cell_coords][0] != null && below_dict[below_cell_coords].get_custom_data(is_fullblock) == true:
				valid = false
				print("Errorcheck 4: in a stack")
		
	
	return valid

I can provide more context if needed. Absolutely baffled why something is returning an error when it works a line above and where the syntax and variable types work when used exactly the same (as far as I can tell) in other functions.

Thanks!

Should this be below_dict[below_cell_coords][0].get_custom_data(is_fullblock)?

1 Like

…yes, thank you, I say as I facepalm right into the sun. The debugger was giving me the line number with the one that had an index so I didn’t even think to look at the next line down :upside_down_face:. I will do some more testing to make sure then close this if the errors all stop. I suppose it’s not baby’s first game without mistakes like this lmao. Thanks again

1 Like