ID:1693261
 
(See the best response by Kaiochao.)
Problem description:
I can't manage to get animate() to work properly on my Show_Damage() proc:

Code:
#define DMG_Font_Width 14

mob/proc

Show_Damage(var/Damage)


var
Num_Pos = 1
Num_Length = length(Damage)

while(Num_Pos<Num_Length+1)

var/Number = copytext(Damage, Num_Pos, Num_Pos+1)

var/image/i = image('Damage_Font.dmi',"[Number]",pixel_y = 36, layer = MOB_LAYER+2)

switch(Num_Length)

if(1)
i.pixel_x = Num_Pos * DMG_Font_Width - 4
if(2)
i.pixel_x = Num_Pos * DMG_Font_Width - 12
if(3)
i.pixel_x = Num_Pos * DMG_Font_Width - 18

src.overlays += i
Num_Pos += 1
spawn(10) src.overlays -= i


I have tried putting it in various places such as:
            src.overlays += i
animate(i, alpha=0, pixel_y=64, time=5)


And:
                if(1)
i.pixel_x = Num_Pos * DMG_Font_Width - 4
animate(i, alpha=0, pixel_y=64, time=5)


Both which end up making my code nonfunctional.

Any help would be appreciated.. :)
Best response
Overlays can't be animated. However, you can animate images that are attached as an image would be.
var image/i = image(..., loc = src)
(something) << i
animate(i, ...)
spawn(10) del i

Images attached this way must be explicitly displayed to specific clients. If you had a reference to the attacker, you could display the number only to the mobs involved:
// (something) = list(src, attacker)
list(src, attacker) << i

Or you could probably simply display it to every client in the world, as an overlay would be:
world << i
Thanks, solved the problem! :)