ID:146836
 
(for the people who just read my Byond Q&A post, yeah that wasn't very long, was it?)

In some games, there is a special turf on the water where it touches land to create a "coastline"... I hate mapping all of these, because you need to put allllll the north's, allll the souths, alllll the wests, alllll the easts...plus for corners that's double the work... I need a way to generate turfs on top of the water where it touches the water. This is what I was thinking about:

world/New()
var/turf/water/W
for(W in world)
for(var/turf/T in locate(W.x,W.y+1,W.z))
if(T.type != /turf/wall) //get the "layered" effect ^_^
continue
else
new /turf/coastn(W.loc) //northcoast overlay
//(repeat for other 3 compass directions)

turf/coastn
icon = 'blah.dmi'
icon_state = "The Bestestest Icon State Ever" //its 4 AM I can call it WHATEVER I want!
layer = 5 //I'm not sure this will help, but...


I tried something like that, but it didn't do anything I could see... it did generate the coasts it just didn't have them on top of the water... I could use icon overlays I think... I'll have to read up on them though (which I'll do). I'd still like to know what's wrong with the above for future knowlage =)
Locate, used in that fashion, will return the turf at those coordinates. So you're looping through all the turfs inside that particular turf. The coastlines will only be put on a turf of the type /turf/wall.

...

Don't you have a ..() statement in world/New()? You might want to put one, then spawn(1) before you run the proc, just to make sure all the turfs exist.
What you need to do is look into methods of autojoining your icons. One handy reference is already available at BYONDscape.

Dream Tutor: All Together Now

If you've set up your coastlines well, chances are you don't need full 47-state autojoining which is a standard, and you can use Foomerian 13-state joining instead. This reduces the possible values to 9 states: Completely filled, straight sides, single outer corners, and single inner corners. Examples:
Filled   Side   Outer   Inner
 XXX     ~~~     ~~~     XX~
 XXX     XXX     XX~     XXX
 XXX     XXX     XX~     XXX

In Foomerian 13-state joining, there are two rules you must follow: Anywhere you have a 13-state autojoining tile, it must be part of a 2×2 block; it can't just jut out on its own or form a thin branch. There must be another next to it east/west, another next to it north/south, and one diagonally between those. For example:
XX        YY
XXXX      YYYYYY
 XXX       YYY
 XX        YY

The example on the left is valid because none of the X tiles "stick out". In the example on the right, the rightmost Y tiles form a thin outcropping.

The second rule is that you can't have two of those 2×2 blocks joined at just the corner. For example:
~XX
XXX
XX~

If you allow that, you have two interior corners on the same icon (the middle one in that example), and you'd need two new icons to handle that. Then this becomes 15-state joining (which is not related to the common 16-state which is explained in the article).

The same code that handles 47-state joins will work for 13-state joins, so all you need to do is include the icon states 7, 14, 28, 56, 112, 127, 131, 193, 223, 224, 247, 253, and 255. If you disregard that 2nd rule and go for a 15-state join, then you also need states 119 and 221.

Lummox JR
In response to Lummox JR
O_O

Woah. I only understood about half of that.

Although the tutorial link explains it really well.