Sets a cell to a terrain, or empties it, then picks the right tile for it and its 8 neighbours. Neighbours that aren't this terrain are left alone, and the edge of the map counts as the same terrain. Takes map (The map's handle), layer (The layer's number, from tmAddLayer or tmGetLayer), x (The tile column, from 0), y (The tile row, from 0), terrain (The terrain number from tmSetTerrain, or 0 to empty the cell). Returns nothing.
map
Int
layer
Int
x
Int
y
Int
terrain
Int
tmSetTileAuto(map, ground, x, y, 1)