ID:1257988
 
(See the best response by Dariuc.)
Code:
turf

receive_edge(tile_icon = edge_icon, tile_state, tile_weight, tile_direction)
var/image/overlay_image = image(tile_icon, tile_state, layer = TURF_LAYER + 0.01 * tile_weight, dir = tile_direction)

var
icon/current = icon(src.icon, src.icon_state)
icon/overlay = icon(overlay_image.icon, overlay_image.icon_state, overlay_image.dir)
/*
// world << "CURRENT DIR: [getdir(src.dir)]"
// world << "IMAGE DIR: [getdir(edge_overlay_image.dir)]"

// world << "TILE ICON: [tile_icon]"
// world << "TILE STATE: [tile_state]"

world << "<font size = +1>[++indice]"

world << "SRC: \icon[icon]"
world << "CURRENT: \icon[current]"
world << "OVERLAY: \icon[overlay]"
*/


current.Blend(overlay, ICON_OVERLAY)

src.icon = current

generate_cardinal_edge()
if(edged || !requires_edges) return NULL

var/north = needs_edging(get_step(src, NORTH))
var/south = needs_edging(get_step(src, SOUTH))
var/east = needs_edging(get_step(src, EAST))
var/west = needs_edging(get_step(src, WEST))

if(north)
north = get_step(src, NORTH)
north:receive_edge(edge_icon, get_edge_clash_state(src, north), weight, NORTH)

if(south)
south = get_step(src, SOUTH)
south:receive_edge(edge_icon, get_edge_clash_state(src, south), weight, SOUTH)

if(east)
east = get_step(src, EAST)
east:receive_edge(edge_icon, get_edge_clash_state(src, east), weight, EAST)

if(west)
west = get_step(src, WEST)
west:receive_edge(edge_icon, get_edge_clash_state(src, west), weight, WEST)

edged = 1


Problem description:
What this piece of code is supposed to do, is basically neighboring tiles around src and, if compatible, combine the necessary edge graphic with src's icon. It works fine until you get another tile that needs its edged applied nearby. For example:

x = dirt
y = grass


1 --- x-x-x-x-x-x-x
2 --- x-x-y-x-y-x-x
3 --- x-x-x-x-x-x-x
----- 1 2 3 4 5 6 7

I can call generative_cardinal_edges() for the grass tile at 3, 2 and it works fine, but if I go ahead and call said function for the grass tile at 5, 2, the dirt tile at 4, 2 will refresh as if I did not call its Blend(icon, ICON_OVERLAY) (so in essence the icon gets rid of the previous edge overlay and places the new, when it's supposed to overlay the new on top and keep both).

The debug messages in the code output everything I need to know, and surprisingly I'm not seeing anything out of the ordinary. It just seems like Blend() isn't working correctly, though I know it works, because I did this same thing yesterday and got it to work, but I don't remember exactly what I did (I overwrote the code on accident when writing this).

Thanks for any help. I've been trying to figure out the issue all day now, and I'm more than positive it's something simple.

Best response
I have seen games where they have multiple top turfs. I believe you have to have a new layer for each topturf you want to place. If you want 2 top turfs, the bottom layer 1, the one above that layer 2 and so on-- otherwise the turf on the same layer will get replaced. Just my thought on it, since I've never needed to use multiple top turfs, but have noticed that behavior when it comes to using top turfs.
The intended behavior is not to create more than one turf on one tile.

What I'm trying to do is get Blend() to stop overwriting the previous updated appearance and just add the new overlay image, but instead, it'll work the first time and overwrite it every time after that. Here is a video showing exactly what I mean: (Link).

As seen in the video, that dirt tile was updated with a random edge overlay, so the new icon includes that edge. Now, when I double-click it again, it'll put another edge on it, BUT overwrite the last edge. That is the problem.

Thanks for the response. I just need to know what in the code I posted above is making the icon reset its appearance, or what I'm doing wrong this time.
In response to Kamakiri
Even if you aren't trying to update a tile with more than one turf, the issue is probably still occuring for the same reason. I'm not entirely sure about that, but you could try specifying a layer to each overlay before it's added to test it.
It's not adding any overlays in this instance. What it does is create an image of the overlay, and then create an icon object of that image, and then uses Blend() on the turf's icon and the image's icon object, setting turf's icon to the newly Blend()ed icon.

I tried putting the overlays on the turf itself prior to Blend()ing, and that did not work either.
This reminds me of an issue I have had before.
For some reason after I edit an icon(say swap colors out on it),if I later try to reference that icon like src.icon while trying to create an image, it shows up as the original file. Most likely-- that's what the problem is in this instance as well.

While I am not entirely sure how to fix this, if you can somehow store the changed icon then access it, that should solve your problem since it seems like the same case.
Ah. I just saw a post of yours with an issue similar. I tried using fcopy_rsc() and that did not work either. (Though I'm pretty confused, because the last time I didn't have this issue at all. I'm going to try just redoing all of it 100% and see if it comes out different. Pretty frustrated at this point.)
Turns out the issue wasn't Blend() at all, haha.

Thanks for your help, Dariuc. I got help from Dan, I'm good now.

/closed