ID:1067175
 
Not a bug
BYOND Version:496
Operating System:Windows XP Home
Web Browser:Chrome 23.0.1271.64
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
When creating new turfs during runtime, the behavior DM provides in the map editor is lost. So, after creating my own underlays preservation within the building procedures. (Save underlays in a list, perform actions for new turf, apply underlays)

However, there is a small dispute here. If you define child turfs, and try to use this, it seems to fail. For example, creation /turf/Grass/Grass1, and then trying to build /turf/Grass/Grass1/Grass_ELeft over it, the underlays fail to preserve. Yet, when I build something such as a sand edge, it works perfectly fine. The same goes for all types; A grass edge on sand is fine, but a sand edge on sand fails as well. It seems things of the same type cannot preserve underlays?

Numbered Steps to Reproduce Problem:
Try to create a turf at runtime which is a child of the turf being replaced, with the latter turf being 'preserved' as an underlay.

Code Snippet (if applicable) to Reproduce Problem:
mob
Move()
var/turf/oldloc = loc
. = ..()
if(on)
if(oldloc != loc)
build()

var
targ
nid = "Build!"
id = 0
on = 0

proc
build(par)
var/test = par
var/list/olays = list()
var/turf/t = loc
olays.Add(
t.overlays,
image(icon = t.icon, icon_state = t.icon_state, dir = t.dir, layer = t.layer),
t.underlays)
if(test)
nid = par
if(id != nid )
on = 1
id = nid
else if(id == nid)
on = 0
id = 0
return
var/turf/nt = new targ(loc)
nt.AddUnderlay(olays)
if(buildinside)
new /area/Inside(loc)
return

build_tile(t2p, b)
targ = t2p
build(b)

obj
Build
Click()
..()
usr.build_tile(t2p, name)
var
t2p


Expected Results:
Allow all child turfs to be able to replace their parents and preserve their images as underlays

Actual Results:
Turf fails to preserve it's predecessor as an underlay

Does the problem occur:
Every time? Or how often? Every time
In other games? Never tried it in other games
In other user accounts? Haven't tested that
On other computers? Nor have I tested this

When does the problem NOT occur?
It always occurs to my knowledge.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? I haven't checked these either, but I would imagine it's the same for each build.

Workarounds:
There was a change in 455 to the behavior of the click in the map editor. Ctrl+click now does this addition, whereas Click is a whole tile replacement. I think that may be all you're seeing. This behavior is configurable in the menu if you prefer it the old way.
Yeah, I'm aware of that. I'm talking about placing tiles at runtime though, which the players will be doing as the game is up. Same type turfs wont take their predecessor as an underlay, the transparent space just turns black. The code is working as expected though, because different type turfs preserve the preceding turf as an underlay.
What are the icon and icon_state settings for the grass/sand and grass/sand edges? If an underlay/overlay has a blank icon or icon_state, it inherits the icon or icon_state (respectively) from the object it is attached to (same goes for direction).

I can't think of a combination of those settings that would give you the behavior that you're describing (where it works for grass on sand, but not grass on grass or sand on sand), but it may still be the culprit.
turf
icon = 'Turfs.dmi'
var
Flyable = 1

Grass
Grass1
icon = 'BrightGrass.dmi'
Grass_Patch
icon_state = "Grasspatch"
Grass_ELeft
icon_state = "E_Left"
Grass_ERight
icon_state = "E_Right"
Grass_ETop
icon_state = "E_Top"
Grass_EBottom
icon_state = "E_Bottom"
Grass_ETR
icon_state = "E_TR"
Grass_EBR
icon_state = "E_BR"
Grass_ETL
icon_state = "E_TL"
Grass_EBL
icon_state = "E_BL"

Nature
Snow
icon = 'Snow.dmi'
Snow_Patch
icon_state = "Snowpatch"
Ice1
icon = 'Ice1.dmi'
DesertSand
icon = 'DesertSand.dmi'

DS_West
icon_state = "ds_west"
DS_East
icon_state = "ds_east"
DS_North
icon_state = "ds_north"
DS_South
icon_state = "ds_south"
DS_Northwest
icon_state = "ds_northwest"
DS_Northeast
icon_state = "ds_northeast"
DS_Southwest
icon_state = "ds_southwest"
DS_Southeast
icon_state = "ds_southeast"
DSC_Northwest
icon_state = "dsc_northwest"
DSC_Northeast
icon_state = "dsc_northeast"
DSC_Southwest
icon_state = "dsc_southwest"
DSC_Southeast
icon_state = "dsc_southeast"


DSC are the desert sand edges.

I define the icon in the parent, and set the icon_state for each version, same as all the turf hierarchy do.
Yea, they're just inheriting like I thought. Give your base state an actual name instead of leaving it blank and the problem will go away.

It works fine when mixing them because 'BrightGrass.dmi' doesn't have a "ds_east" state, so it ends up showing the blank state anyways.
Hm.. I'm not sure what you mean.. Oh, you must mean in the icon? Interesting. I'll try that out.

Edit: You're right, DarkCampainger. It's awesome how you always seem to know those little details. This isn't exactly a bug then, it's just inheritance and me not expecting it to work that way.
DarkCampainger resolved issue (Not a bug)