ID:2081968
 
(See the best response by GreatPirateEra.)

Problem description: Currently do not have a code, I have literally no idea on how to approach this. When I was younger every commercial game (pretty much) had a system like this prior to voice acting becoming the norm. What I want is to be able to come up to an NPC talk to them and boom a HUD appears with the NPCs text (may it be a generic text or their personal text) clicking or hitting a button to make it scroll down/end the conversation (I assume most of you know the idea) and so on. How would I go about this? (pictures for reference in case no one understands what I am talking about)



Best response
Well, you need to look into:
client.screen
screen_loc
images
maptext

A var to store what each npc says, defaulting to a generic greeting or w.e if they don't have anything to say, and a key_down() tracker. This is extremely simple to set up.
So I need the hud for the box and the maptext definition (prior to it updating via the NPCs) on the same object or can I define them separate and mash them together? (Via making either 1 object or making 2 and calling them together o.o)
var
list/Line1[]=list("Hi")
i
mob
var
list/line1[]=list("Hi")
friendly
oozy
line1=list("Stuff","<b>Stuff and whatnot")
ai()
interact(mob/m)
nomoartext()
src.ChangeText()
m.hudtext_hud2()
usr.client.focus = usr.text_box1
mob/proc/ChangeText()
Line1=src.line1
proc/nomoartext()
Line1=null
mob
cleartext_hud()
..()
if(text_box1)
text_box1.hide()
del text_box1
Textbox1
parent_type = /HudGroup
layer = Constants.HUD_LAYER+1
New(mob/m)
..()
usr.showtext_hud()
refresh()


key_down(k)
if(k == Constants.KEY_SELECT)
if(Line1[i]+1==null)
usr.client.focus = usr
usr.cleartext_hud()
else
refresh()
proc/refresh()
var/icon/textbox = 'Text Screen.dmi'
if(isfile(textbox))
textbox = icon(textbox)
else if(istext(textbox))
textbox = icon(Constants.HUD_ICON, textbox)
var/lx = Constants.ICON_WIDTH * Constants.VIEW_WIDTH * 0.5 - textbox.Width() * 0.5
var/ly = Constants.ICON_HEIGHT * Constants.VIEW_HEIGHT * 0.5-70 - textbox.Height() * 0.5-70
for(i=1, i<=Line1.len, i++)
Line1[i] = i
add(lx+5,ly+20 , "", maptext_width = (Constants.VIEW_WIDTH * Constants.ICON_WIDTH)-65, maptext_height=(Constants.VIEW_WIDTH * Constants.ICON_WIDTH)-720, maptext = "<text align=top><b>[Line1[i]]", layer = layer + 1)

mob
var
tmp/Textbox1/text_box1
proc
hudtext_hud2()
text_box1 = new(src)

What I came up with. Right away I separated the objs and texts however when the second one popped up and I pressed space but nothing happened. So then I tried a list, numbers are appearing and it doesn't switch on refresh. Require a little help :/

Using http://www.byond.com/developer/Forum_account/ HudGroups?tab=index
var
list/Line1[]=list("Hi")
i=1
mob
var
list/line1[]=list("Hi")
friendly
oozy
ai()
interact(mob/m)
var/list/L=list("1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26","Stuff and whatnot")
line1=L
src.ChangeText()
m.hudtext_hud2()
usr.client.focus = usr.text_box1
mob/proc/ChangeText()
Line1=src.line1
src.line1=null

changed this and

    key_down(k)
if(k == Constants.KEY_SELECT)
if(i==Line1.len)
usr.cleartext_hud()
else
i+=1
refresh()
proc/refresh()
var/icon/textbox = 'Text Screen.dmi'
if(isfile(textbox))
textbox = icon(textbox)
else if(istext(textbox))
textbox = icon(Constants.HUD_ICON, textbox)
var/lx = Constants.ICON_WIDTH * Constants.VIEW_WIDTH * 0.5 - textbox.Width() * 0.5
var/ly = Constants.ICON_HEIGHT * Constants.VIEW_HEIGHT * 0.5-70 - textbox.Height() * 0.5-70
del(text)
text = add(lx+5,ly+20 , "", maptext_width = (Constants.VIEW_WIDTH * Constants.ICON_WIDTH)-65, maptext_height=(Constants.VIEW_WIDTH * Constants.ICON_WIDTH)-720, maptext = "<b><font face=verdana><font size=2.5><text align=top>[Line1[i]]", layer = layer + 1)
Line1[i] = i

Resolved the issue without further help thank you regardless greatpirate. This is done if the byond admins want to lock it and what not
You have some usr abuse in the code you posted. In a proc, you should never use usr.
I see it, I thought it was src xD thank you for pointing it out I will fix that