Autojoining walls can save you the trouble of setting each wall section's icon_state in the map editor; just leave them as the default unnamed state and they will join up at boot time. Walls created and deleted at runtime will also join correctly with their neighbours. To create an icon for an autojoining wall, assign a bit to each direction:
| North: | 1 |
| Northeast: | 2 |
| East: | 4 |
| Southeast: | 8 |
| South: | 16 |
| Southwest: | 32 |
| West: | 64 |
| Northwest: | 128 |
The default icon_state, which will never be seen by players, should be left unnamed, and its image should include a graphical hint that it is the default unjoined state. The names of the other icon_states should be the bitwise OR (in decimal) of the bits for the directions in which this state is joined.
16 state walls require the following states; click here to download an example .dmi file:
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| 0 | 1 | 4 | 5 | 16 | 17 | 20 | 21 | 64 | |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| 65 | 68 | 69 | 80 | 81 | 84 | 85 |
47 state walls require the following states; click here to download an example .dmi file:
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| 0 | 1 | 4 | 5 | 7 | 16 | 17 | 20 | 21 | |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| 23 | 28 | 29 | 31 | 64 | 65 | 68 | 69 | 71 | 80 |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| 81 | 84 | 85 | 87 | 92 | 93 | 95 | 112 | 113 | 116 |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| 117 | 119 | 124 | 125 | 127 | 193 | 197 | 199 | 209 | 213 |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
||
| 215 | 221 | 223 | 241 | 245 | 247 | 253 | 255 |
256 state walls require a state for every combination of directions (no graphics available yet).
// When a turf's AutoJoin proc is called, the turf will probably not be the only
// object whose icon_state must be changed; adjacent turfs of the same type must
// also be changed. For turfs created at runtime, this can be achieved with a
// recursive AutoJoin proc, called from the New proc. However, this recursion is
// redundant for turfs in compiled-in map files, because the New procs of the
// adjacent turfs will be called at boot time. Autojoin recursion at boot time
// can be prevented by providing an autojoin_recurse variable, initially 0 but
// set to 1 by world.New().
/var/autojoin_recurse = 0
/world
New()
autojoin_recurse=1
// OffMap returns true if the given co-ordinates are off the map, otherwise it
// returns false.
/proc/OffMap(x,y,z)
return (x<1)||(x>world.maxx)||(y<1)||(y>world.maxy)||(z<1)||(z>world.maxz)
// Separators divide a level of the map into multiple smaller maps. They must
// emulate the behaviour of the edge of the map.
/turf/separator
name = ""
icon = 'generic/black.dmi' // A single unnamed state, solid black
density = 1
luminosity = 0
opacity = 1
visibility = 1
Click(Location)
// Do nothing.
DblClick(Location)
// Do nothing.
Enter(O)
// To emulate the edge of the map, non-dense objects must be blocked.
var/saved_density = O:density
O:density=1
.=..(O)
O:density=saved_density
// Walls are dense, opaque, visible and non-luminous.
/turf/wall
density = 1
luminosity = 0
opacity = 1
visibility = 1
/turf/wall/auto
New(Loc)
..(Loc)
// AutoJoin the wall, and recurse into neighbours if this is not
// boot-time.
AutoJoin(autojoin_recurse)
Del()
// Before deleting an autojoining wall, set its visibilty to 0 so that
// its neighbours won't recognize it when autojoining.
visibility=0
// Then autojoin the wall with recursion 1 to update the icon_states of
// the neighbours.
AutoJoin(1)
// Finally, delete the wall.
..()
proc/AutoJoin(r)
// Stub.
//
// Subclasses of /turf/wall/autojoin will define which neighbours can be
// autojoined with.
proc/AutoJoinDir(dx,dy,r)
var/turf/t
// Even if the neighbour is off the map, this turf may need to autojoin
// with it.
if (OffMap(x+dx,y+dy,z))
return EdgeMatch()
// Get reference to neighbour.
t=locate(x+dx,y+dy,z)
// Separators are treated the same way as off-map turfs.
if (istype(t,/turf/separator))
return EdgeMatch()
// Turfs of the same type are eligible for autojoining.
if (t.type==type)
// If recursing, call AutoJoin on neighbour.
if (r)
t:AutoJoin(r-1)
// Autojoin with visible turfs only.
return t.visibility
return 0
// If a turf, at the edge of the map or adjacent to a turf that emulates the
// edge of the map, should appear to be autojoined to "virtual" turfs off
// the edge, EdgeMatch should return 1, otherwise it should return 0.
proc/EdgeMatch()
return 0
// Note that in the following types derived from /turf/wall/auto, the number of
// states refers to the number of icon_states excluding the default unjoined
// state; a 16 state wall actually has 17 icon_states, but only 16 of them are
// numbered.
// 16 state walls can autojoin to any combination of the four orthogonally
// adjacent turfs.
/turf/wall/auto/s16
AutoJoin(r)
var/s = 0
s|= AutoJoinDir( 0, 1,r)
s|= AutoJoinDir( 1, 0,r)<<2
s|= AutoJoinDir( 0,-1,r)<<4
s|= AutoJoinDir(-1, 0,r)<<6
icon_state="[s]"
// 47 state walls can autojoin to any combination of the four orthogonally
// adjacent turfs plus any diagonally adjacent turf for which the surrounding
// orthogonally adjacent turfs have been autojoined.
/turf/wall/auto/s47
AutoJoin(r)
var/s = 0
s|= AutoJoinDir( 0, 1,r)
s|= AutoJoinDir( 1, 0,r)<<2
s|=((s& 5)== 5)?(AutoJoinDir( 1, 1,r)<<1):0
s|= AutoJoinDir( 0,-1,r)<<4
s|=((s&20)==20)?(AutoJoinDir( 1,-1,r)<<3):0
s|= AutoJoinDir(-1, 0,r)<<6
s|=((s&80)==80)?(AutoJoinDir(-1,-1,r)<<5):0
s|=((s&65)==65)?(AutoJoinDir(-1, 1,r)<<7):0
icon_state="[s]"
EdgeMatch()
// This nearly always looks "right" for 47 state walls.
return 1
// 256 state walls can autojoin to any combination of the eight adjacent turfs.
/turf/wall/auto/s256
AutoJoin(r)
var/s = 0
s|= AutoJoinDir( 0, 1,r)
s|= AutoJoinDir( 1, 1,r)<<1
s|= AutoJoinDir( 1,-1,r)<<3
s|= AutoJoinDir( 1, 0,r)<<2
s|= AutoJoinDir( 0,-1,r)<<4
s|= AutoJoinDir(-1,-1,r)<<5
s|= AutoJoinDir(-1, 0,r)<<6
s|= AutoJoinDir(-1, 1,r)<<7
icon_state="[s]"