Error on TileSet tile_get_shape_count

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

I’m trying to identify cells in a TileMap that does not have a collisionshape, and are also in-between cells that do have collisionshapes in order to flag them as entry points.

The code seems to do what it should, but Godot seem to give me an error if the shape count is 0. Is there a better way to go about this or am I misunderstanding the error?

Error:
E 0:00:00.467 tile_get_shape_count: Condition “!tile_map.has(p_id)” is true. Returned: 0
<C++ Source> scene/resources/tile_set.cpp:745 @ tile_get_shape_count()
Room.gd:30 @ check_is_wall()
Room.gd:18 @ identify_entry_cells()
Room.gd:7 @ _ready()

Code:

onready var floor_map = $Floor
onready var point_map = $Points

func _ready() -> void:
	identify_entry_cells()

func identify_entry_cells():
	var used_cell_positions = floor_map.get_used_cells()
	for cell_position in used_cell_positions:
		var is_wall = check_is_wall(cell_position)
		
		# If current cell does not have a shape, check adjacent cells
		if !is_wall:
			var left_offset = check_is_wall(Vector2(cell_position.x - 1, cell_position.y))
			var right_offset = check_is_wall(Vector2(cell_position.x + 1, cell_position.y))
			var up_offset = check_is_wall(Vector2(cell_position.x, cell_position.y - 1))
			var down_offset = check_is_wall(Vector2(cell_position.x, cell_position.y + 1))
			
			# If adjacent cells on both sides have shapes, current cell is an entry cell
			if left_offset and right_offset:
				# Add a tile above current tile to vizualise entry cell
				point_map.set_cellv(cell_position, 0)
					
			elif up_offset and down_offset:
				point_map.set_cellv(cell_position, 0)

func check_is_wall(cell):
	var tile_id = floor_map.get_cellv(cell)
	var tile_shapes = floor_map.tile_set.tile_get_shape_count(tile_id)
	if tile_shapes == 0:
		return false
	else:
		return true