Is way to change a tile in a tileset based on the bitmap of the tiles around it?

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

So I’m trying to recreate the style that celeste uses in its tilesets, where there is a transition tile between the outer edge tiles and the inside of the tileset, I currently managed to get it to work using 2 different tilesets and with a script so that they bind

(using celeste’s textures as a placeholder)
This has to be done manually however which gets really tiresome after some time

So I was wondering if there is a way to code this so that if a tile is on the inside and any of the 4 neighbors of a it are exposed to air it picks a random texture from a list of available textures