WriteToOlay(var/atom/m,var/a="Huh",var/lc=0,var/uc=0,var/b as color,var/scale=0,var/fontie='FiraMono8pt_AA2.dmi',var/out=0)
var/g=a
var/leftspot=round((length(g)/2)*-3.65)
for(var/i=1,i<=length(g),i++)
var/obj/N=new/obj/name
N.icon=fontie
N.layer=m.layer+1
N.pixel_x=leftspot+lc
N.pixel_y+=uc
N.icon_state="[copytext(g,i,i+1)]"
if(scale)
var/matrix/z=new
z.Scale(0.5,0.5)
N.transform=z
N.color=b
if(out)
outline_textX(N)
m.overlays+=N
leftspot+=N:wid
//version 2 is...?
ImgToOlay(var/atom/m,var/atom/v,var/a="Huh",var/lc=0,var/uc=0,var/b as color,var/scale=0,var/fontie='FiraMono8pt_AA2.dmi',var/out=0)
var/g=a
var/leftspot=round((length(g)/2)*-3.65)
var/obj/x=new
for(var/i=1,i<=length(g),i++)
var/obj/N=new/obj/name
N.icon=fontie
N.layer=m.layer+1
N.pixel_x=leftspot+lc
N.pixel_y+=uc
N.icon_state="[copytext(g,i,i+1)]"
if(scale)
var/matrix/z=new
z.Scale(0.5,0.5)
N.transform=z
N.color=b
if(out)
outline_textX(N)
leftspot+=N:wid
var/image/h=image(x,m)
m.overlays+=h
v<<h//this doesn't seem to work.
Problem description:
I'm trying to convert this proc *which writes to an atom's overlay* into a proc that converts all text into a single image which can then be applied for only the intended viewer.
Basically this is used similiar to how NESTALIA does their screen objects *one object for all to use, but info that is player specific*.
But a few pointers anyway:
A lot of your stuff could be moved outside of the loop, rather than inside. outline_text should be done after all the letters are added, not for each letter. That way you only have to duplicate the appearance 4 times rather than 4*N times.
Further, scaling should be done after the construction of the overlays, not during.
Also there's no need to create an object per letter every iteration. We can recycle the same object for each letter because the objects won't persist, only their appearance will be used.