Getting autotile to work in procedurally generated maps

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

Trying to get autotiling to work with procedural generation.

The code I have to create walls, and then dig out a path:

func generate_level():
	# Fil map with walls
	for x in range(0, map_width + 2):
		for y in range(0, map_height + 2):
			map_walls.set_cell(x,y, 0)
	# Maze function for most floors
	# Walker function for warrens
	var walker =, (map_height/2)), borders)
	var map = walker.walk(1000)
	for location in map:
		map_floors.set_cellv(location, _pick_random_texture(Cell.WARREN))

What happens:
Autotile not working, but the floor randomization is

What I expect:
Hand-drew this as an example

I’ve triple-checked the bitmask for the autotile, and it always works if I hand-draw the levels. But when generating the levels, the autotile just won’t update the bitmask.

If I try to update the bitmask area instead of the region, I get:
enter image description here