obj
F_damage_num
layer = 10000
var
F_damageValue
proc/F_damage(atom/Target, value, color)
color=colour2html(color)
//var/icon/I = new('F_damageFade.dmi')
//I.Blend(color, ICON_MULTIPLY)
var/list/Numbers = new()
var/string = num2text(value)
var/counter = 0
var/strLength = length(string)
while(string)
var/obj/F_damage_num/O = new(null)
O.pixel_x = counter*(-7) + Target.pixel_x + round(strLength*7/2)+7
O.pixel_y = Target.pixel_y + 25
O.F_damageValue = copytext(string, length(string))
//O.icon = I
Numbers += O
string = copytext(string, 1, length(string))
counter++
for(var/obj/F_damage_num/O in Numbers)
O.loc = Target:loc
flick(O.F_damageValue, O)
spawn(10)
del O
Problem description:
This makes the game lag like hell, the three lines commented out above fix the lag though, so I was wondering if there way to cache the icon for next time, so the first time it calls the proc, it creates the icon for that color, and then after, it just uses it, but it seems it makes it each time every time which is why it lags.
If I make it choose icon based on color then it works fine if I make an icon file for that of each color, but I don't want to do that.