ID:152628
 
I am a bit self-conscious about my own code being ugly, and inefficient. So, I am reaching out on a few design pointers, and stuff that I can store into my memory bank for future reference.

screen_text
var
icon
avg_width


CourierNew8pt
icon = 'CourierNew8pt'
avg_width = 8


proc
drawText(client/C, txt, x=1, y=13, color="#FFF", ch_per_line = 30)
var/ch
var/px = 0
var/py = 0
var/_x = x
var/c_p_l = ch_per_line
for(var/i = 1 to length(txt))
ch = copytext(txt, i, i+1)
px += avg_width
var/obj/letter/O = new
var/icon/I = icon(icon, ch)
I.Blend(color)
O.name = ch
O.icon = I
O.screen_loc = "[x]:[px],[y]:[py]"
C.screen += O
if(px >= 32)
px = 0
x ++
if(ch_per_line <= i)
ch_per_line += c_p_l
py -= 16
px = 0
x = _x
if(py <= -32)
py = 0
y--


Try not to faint. =P

PS:
var/_x = x
var/c_p_l = ch_per_line
Shouldn't the initial() work in replacement of these vars? I tried it but it just wouldn't work, thanks for any replies that might follow.