ID:1399539
 
Struggling with this one. I'm trying to create a damage indicator that shows over the mob when it takes damage.

- The first obj is a red star.
- The second object is the text that I want to center over the red star.
- Then I want to attach the red star and text over the mob taking damage.

What actually happens is I end up with two red stars where one is showing correctly and an unexpected second red star is offset by 16 pixels. and without text.

Running 500.1213

var/obj/damage/d = new() // Damage counter that shows when monster is hit.
d.layer = DUNGEON_LAYER + 3

var/obj/a = new()
a.maptext = "<font size=2 color=white>34</font>"
a.pixel_x = 16 // center the text on the damage counter

d.overlays += a // Attach the offset maptext obj to the damage indicator.

m.overlays += d // Attach the damage indicator to the mob taking damage.


I saw another post where there was a discussion about some special client layer and I couldn't be sure if I was experiencing the same thing or not.
Of course, as soon as I hit Save it occurred to me that I could work around the problem by associating the maptext obj with the mob instead of the damage object.

I've worked around my problem.
I won't mark this as fixed so someone has a chance to determine if its a bug or not.
Shouldn't the maptext also have maptext_width and maptext_height defined?

An overlay will normally take on its parent's icon and/or icon_state if neither is defined. However, it does seem like when maptext is present this behavior should change, and I'd regard that as a bug.

[edit]
Actually I'm wrong; an overlay with no icon and no icon_state is supposed to show neither. I'll investigate.
I can't verify this. My test kitchen using a variant of your code can't reproduce this problem. I'd need a test project from you that shows the issue in action.
I have just tested this and have been able to reproduce your results. At first, I received no issue based on the code you provided, much like Lummox. However, after altering what could cause it, I have recreated it.

I noticed you just have the maptext object created as a base object (var/obj/a). I recreated the problem by defining my default obj to have an icon file...

obj
icon='file.dmi'

This seems to give the maptext the default icon state of the designated file and simply removing that line should solve it. You would then of course always define the icon files in your object tree -- this is what I do and is simple to follow.

Honestly, I have no idea if this was meant to happen in dm but there you have it, hope this helps.