ID:1405771
 
(See the best response by Kaiochao.)
Hey Byond Community,

Code:
NPC_HUD
proc

NPC_Talk(atom/m, obj/NPC, words)

if (!istype(m, /mob/players))
return

if (istype(NPC, /obj/shops))
Small_Box(m, NPC, words)

if (istype(NPC, /obj/active))
Small_Box(m, NPC, words)

Small_Box(atom/at, obj/NPC, words)

if (!istype(at, /mob/players))
return

var/mob/m = at

if (length(m.extended_text))
m.extended_text = ""

m.remove_all_from_screen(/obj/Hud_Controls/blank, 1)
m.remove_all_from_screen(/obj/Hud_Controls/text, 1)
m.remove_all_from_screen(/obj/Hud_Face/face, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_1, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_2, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_3, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_4, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_5, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_6, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_7, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_8, 1)
m.remove_all_from_screen(/obj/Hud_Boxes/Hud_Box_9, 1)

if (!words) return

var/new_words = copytext(words, 1, 35)
var/obj/Hud_Boxes/Hud_Box_1/H1 = new()
m.add_screen(H1)
H1.screen_loc = "1,1"

for (var/a = 2, a < 11, a ++)

var/obj/Hud_Boxes/Hud_Box_2/H2 = new()
m.add_screen(H2)
H2.screen_loc = "[a],1"

var/obj/Hud_Boxes/Hud_Box_5/H5 = new()
m.add_screen(H5)
H5.screen_loc = "[a],2"

var/obj/Hud_Boxes/Hud_Box_3/H3 = new()
m.add_screen(H3)
H3.screen_loc = "11,1"


var/obj/Hud_Boxes/Hud_Box_4/H4 = new()
m.add_screen(H4)
H4.screen_loc = "1,2"

var/obj/Hud_Boxes/Hud_Box_6/H6 = new()
m.add_screen(H6)
H6.screen_loc = "11,2"

var/obj/Hud_Face/face/npc_face = new()
npc_face.screen_loc = "1,2"
npc_face.layer = HUD_LAYER
npc_face.icon = 'Icons/faces.dmi'
npc_face.icon_state = "[NPC.name]"
m.add_screen(npc_face)

var/obj/Hud_Controls/text/mt = new()
mt.screen_loc = "2,2"
mt.layer = TEXT_LAYER
mt.maptext = "[MapText_Font][new_words]</b>"
m.add_screen(mt)

if (length(words) > 35)
m.extended_text = copytext(words, 35, length(words) + 1)
m.extended_NPC = NPC

var/obj/Hud_Controls/blank/b = new()
b.screen_loc = "11,1"
b.layer = HUD_LAYER + 1
b.maptext = "<center><font size = \"1\">[MapText_Font]Next"
m.add_screen(b)


Problem description:

NH.NPC_Talk (usr, src, "For exmaple") <-- does not work
NH.NPC_Talk (usr, src, "Forexample") <-- works fine


I am amusing copytext is not what I use because having spaces in a text is not a sting. So my question would be how do I avoid copytext.
Best response
You should try a debug message to see what new_words comes out to be. I think you might be seeing "For" from "For example" because the second word is being cut off due to the maptext bounds, maptext_width and maptext_height. Be sure to set those accordingly.
I think your issue is with maptext. By default, maptext_width and maptext_height are constrained by to the icon size. Try increasing these variables and see if you can make it work that way.
Lol, every time I mess with maptext_height and maptext_width its game over for me. I will see what I can do.

Edit:
Alright I put world << new_words under var/new_words = copytext(words, 1, 35) and I get full output. it must be with maptext which bothers me.
WAIT!

Why would I change the height and width if my icon size is 32 anyways? o_o

Edit: When I set maptext_width and height it made them look like they are in a box lol.
Correction, Problem solved:

            mt.maptext = "[MapText_Font][new_words]</b>"
mt.maptext_width = 10000
m.add_screen(mt)
Glad you got it working :)
the width can be inf because I cut the length off with copytext anyways. :) Thanks for the help everyone.
Anytime :)