ID:2605127
 
Code:
client/proc/DRAW_TEXT(var/text_string,var/slowText,var/obj/HUD/h)
var/tmp/pixel_x_plus

var/char_pos = 1
var/char_len = length(text_string)

while(char_pos < char_len+1)
var/charInc = 0.2

charCheck
var/T = copytext(text_string,char_pos,char_pos+1)
if (T != " ")
var/image/I = image('HUD/HUD - Font.dmi', h, "[T]", 22) // 'h' is just a location. Could be any location really.

I.transform = I.transform.Scale(0.8,0.8)
I.pixel_x += pixel_x_plus
I.pixel_y = pixel_y_offset
I.mouse_opacity = 1
I.menu_id = m_id
I.name = h.name
src << I

pixel_x_plus += font_width

char_pos++

if (slowText) // Show the text letter-by-letter on screen
while (charInc < world.tick_lag)
charInc += 0.2
goto charCheck
if (!src.skipText)
sleep(world.tick_lag)


Problem description:
Hello! I have a proc that is supposed to display text via images on a clients screen. It works great most of the time, but there are certain situations in which the images stop appearing entirely.

The most consistent way I've found of replicating this is by talking to an NPC in-game (This causes the HUD to appear and the text string to print itself out as multiple images), and while the text is on screen, you leave the game.
Upon reconnecting to the server, and trying to talk to the NPC again, you can't see any of the text anymore. The world and logic are both working fine, the game doesn't freeze up or anything, everything is working as it should, except I can't see the text. I thought it might've been a Byond Version issue but my Byond is up-to-date, so I feel like I'm stuck...

Thanks in advance for your help!
Ah! And one more thing. The issue seems to be fixed upon restarting the server. Hope that helps pin-point the issue.
Hmmm, there's nothing I can see in the code that would cause this problem. Maybe something weird is going on with your login() and logout() behavior?

I would recommend trying some debug messages.

client/proc/DRAW_TEXT(var/text_string,var/slowText,var/obj/HUD/h)
world << "Drawing text for [mob]" //make sure the right mob is linked with this client
var/tmp/pixel_x_plus

var/char_pos = 1
var/char_len = length(text_string)

while(char_pos < char_len+1)
var/charInc = 0.2

charCheck
var/T = copytext(text_string,char_pos,char_pos+1)
if (T != " ")
var/image/I = image('HUD/HUD - Font.dmi', h, "[T]", 22) // 'h' is just a location. Could be any location really.
world << "Placed [T] on [h]" //is the h object being passed correctly?
I.transform = I.transform.Scale(0.8,0.8)
I.pixel_x += pixel_x_plus
I.pixel_y = pixel_y_offset
I.mouse_opacity = 1
I.menu_id = m_id
I.name = h.name
src << I

pixel_x_plus += font_width

char_pos++

if (slowText) // Show the text letter-by-letter on screen
while (charInc < world.tick_lag)
charInc += 0.2
goto charCheck
if (!src.skipText)
sleep(world.tick_lag)
Ah sorry, I should've updated this thread. I managed to fix the issue.

And indeed there was an issue with logging out, but it took me a while to figure out what exactly.
The HUD objects ("h" in this code) are created for each client upon logging in. It then tries drawing onto the HUD object the text images. The problem begins when logging out, because the server does not delete the HUD objects, and so they persist even after the player left.

When the player logs back in, it creates new HUD objects as it should, but the old one is still there. And then when it goes to the DRAW_TEXT proc, it sends over the old HUD object, and that somehow caused the issue, I'm still not sure why it caused the issue but deleting the old HUD objects seemed to fix it haha.

Thanks for the reply though!