This is ONLY for 47 state auto joining. I have never needed anything else, and the standard auto-tile system seen in RPG Maker XP / VX is 47 state joining.
If you need weird state joins, this code isn't for you.
turf
Del()
spawn for(var/auto_tile/a in range(1, src)) a.join()
..()
auto_tile
parent_type = /turf
var
list/matches = null
list/exclude = null
New()
..()
if(!icon_state) src.join()
proc/join()
var/byte = 0
byte = src.match(NORTH, byte, 1)
byte = src.match(EAST, byte, 4)
byte = src.match(SOUTH, byte, 16)
byte = src.match(WEST, byte, 64)
byte = src.match(NORTHEAST, byte, 2, 5)
byte = src.match(SOUTHEAST, byte, 8, 20)
byte = src.match(SOUTHWEST, byte, 32, 80)
byte = src.match(NORTHWEST, byte, 128, 65)
src.icon_state = "[byte]"
proc/match(direction, byte, bit, mask = 0)
if((byte & mask) == mask && src.ismatch(direction)) byte |= bit
else byte &= ~bit
return byte
proc/ismatch(direction)
var/auto_tile/t = get_step(src, direction)
if(!t) return 1
if(istype(t, src.type)) return 1
for(var/v in src.matches)
if(v == direction) return 1
else if(istype(t, v) && !(t.type in src.exclude)) return 1
return 0
To use it, just derive from /auto_tile
environment/cave/floor/auto_tile
parent_type = /auto_tile
icon = 'whatever_auto_tile.dmi'
This allows support for matching via type, and excluding from parent types. It also allows matching to DIRECTION.
floor_to_water
parent_type = /auto_tile
matches = list(/floor, /water)
//this will connect to floors, AND water
floor_base
parent_type = /auto_tile
matches = list(/floor, SOUTH)
//this will connect to floors, and any tile that is SOUTH of this tile
//you can also connect to a whole "type" while excluding a specific part of that parent type
tree_branch
parent_type = /auto_tile
matches = list(/tree) //connect to /tree and all its children
exclude = list(/tree/root) //but don't connect to /tree/root
This expects Lummox JR's state numbering for the icon_states, which can be found in his Icon Cutter utility.