ID:164388
 
Ok i have a problem, i need to know some advanced coding to understand some of these hud demos/libs, im making a Final Fantasy game and a FF game just isnt all that if it dont have its hud, i got the icons (the background the boarders and the text) i just need to be able to understand some stuff, like i found this:

mob/var/tmp
inmenu
menuaction
menuanswer
menupos=1
input_box=0
sleep_in_message
list/menulist = new()
list/text_list = new()
obj/onscreen/curser/curser

mob/proc
//common proc
screen_dialog(text,screen,refresh,quick)
if(!screen) screen="message"
if(!refresh) screen_background(2,16,12,16,0,0,10,screen)
screen_npctext(3,15.5,15,12,0,16,11,text,screen,quick)
screen_yesno(var/screen)
while(text_list) sleep(5)
inmenu="yesno"
screen_background(2,5,9,11,0,0,10,"yesno")
screen_text(3,5.5,10.5,10.5,0,0,10,"Yes","yesno")
screen_text(3,5.5,9.5,9.5,0,0,10,"No","yesno")
menuanswer=0
menupos=1
curser=new(client)
curser.screen_loc="2,10:8"
while(!menuanswer) sleep(5)
close_screen("yesno")
del(curser)
inmenu=screen
if(menuanswer==1) return 1
else return 0
//close proc
close_allscreen()
if(!client) return
for(var/obj/onscreen/O in client.screen) del O
menulist = list()
inmenu = null
menupos = 1
close_screen(var/screentag)
for(var/obj/onscreen/O in client.screen) if(O.screentag == screentag) del O
//listing proc
screentext2listl(var/text)
var/list/textlist = new()
for(var/a=1,a<=length(text),a++) textlist+=copytext(text,a,a+1)
return textlist
//*menu creation proc*
screen_background(XC1,XC2,YC1,YC2,XO,YO,layr,screentag)
for(var/XC=XC1,XC<=XC2,XC++)
for(var/YC=YC1,YC<=YC2,YC++)
var/obj/onscreen/back/BG=new(client,layr,screentag)
if(XC==XC1) BG.icon_state="l"
else if(XC==XC2) BG.icon_state="r"
else if(YC==YC1) BG.icon_state="b"
else if(YC==YC2) BG.icon_state="t"
if(XC==XC1&&YC==YC1) BG.icon_state="ll"
else if(XC==XC2&&YC==YC2) BG.icon_state="ur"
else if(XC==XC1&&YC==YC2) BG.icon_state="ul"
else if(XC==XC2&&YC==YC1) BG.icon_state="lr"
BG.screen_loc="[XC]:[XO],[YC]:[YO]"
//**NPC text we can use this for**
screen_npctext(XC1,XC2,YC1,YC2,XO,YO,layr,text,screentag,quick)
for(var/obj/onscreen/text/O in client.screen) if(O.screentag==screentag) del(O)
if(text) text_list = screentext2listl(text)
else if(text_list) for(var/L in text_list) text+=L
else return //nothing to display
var
XC=XC1
YC=YC1
if(!quick) sleep_in_message = 0
var/C=1
for(C,C<=length(text_list),C++)
//spacin', paragraph..
if(text_list[C]==ascii2text(35)){XC=XC1;YC-=1;continue}
else if(text_list[C]==ascii2text(32)) //a space
//do we have enough place for the next word? looking for '#' or ' '. x_x
var/space_left = (((XC2-XC1)-(XC-XC1))*2)
if(length(copytext(text,C+1,findtext(text,ascii2text(32),C+1,0)))>space_left&&length(copytext(text,C+1,findtext(text,ascii2text(35),C+1,0)))>space_left){XC=XC1;YC-=1;continue}
if(XC==XC1) continue //is it the beginning of a line? x_x
//paragraph
if(XC>XC2){XC=XC1;YC-=1}
if(YC<YC2)
text_list.Cut(1,C)
var/obj/onscreen/text/N = new(client,layr,screentag)
N.screen_loc="18,12"
N.icon_state=ascii2text(62)
sleep_in_message = 0
return
//creating the obj/icon
var/obj/onscreen/text/T = new(client,layr,screentag)
if(XC==round(XC)&&YC==round(YC)) T.screen_loc="[XC]:[XO],[YC]:[YO]"
else if(XC!=round(XC)&&YC==round(YC)) T.screen_loc="[XC-0.5]:[16+XO],[YC]:[YO]"
else if(XC==round(XC)&&YC!=round(YC)) T.screen_loc="[XC]:[XO],[YC-0.5]:[16+YO]"
else if(XC!=round(XC)&&YC!=round(YC)) T.screen_loc="[XC-0.5]:[16+XO],[YC-0.5]:[16+YO]"
T.icon_state = text_list[C]
//end of creation
if(sleep_in_message) sleep(1)
XC+=0.5
text_list = null
sleep_in_message = 0
//***This part is good for huds***
screen_text(var/XC1,XC2,YC1,YC2,XO,YO,layr,text,screentag)
var XC=XC1,YC=YC1
for(var/i=1,i<=length(text),i++)
var/C = copytext(text,i,i+1)
if(C==ascii2text(35)){XC=XC1;YC-=0.5;continue}
var/obj/onscreen/text/T=new(client,layr,screentag)
if(XC==round(XC)&&YC==round(YC)) T.screen_loc="[XC]:[XO],[YC]:[YO]"
else if(XC!=round(XC)&&YC==round(YC)) T.screen_loc="[XC-0.5]:[XO+16],[YC]:[YO]"
else if(XC==round(XC)&&YC!=round(YC)) T.screen_loc="[XC]:[XO],[YC-0.5]:[16+YO]"
else if(XC!=round(XC)&&YC!=round(YC)) T.screen_loc="[XC-0.5]:[XO+16],[YC-0.5]:[16+YO]"
T.icon_state="[C]"
XC+=0.5
if(XC>=XC2){XC=XC1;YC-=0.5}
if(YC<=YC2-0.5) break


and i dont understand that at all, its hardly (if at all) commented, and i dont understand it... did i mention i dont understand that? i mean im a good enough coder but i havent EVER wandered into making a hudded game, now i cant really progress with my game any more unless if i learn how to use that, because like everything revolves around the hud, battle/menu/invitory/status/equipment you name it FF has a hud for it...

anyone willing to teach me the way of the hud?
okay forget the peice of coding above, i need help learning how to make a FF (Final Fantasy) like hud system that i can understand. thanks
In response to VolksBlade
Look up "screen var (client)" and "screen loc var (movable atoms)" in the reference. Play around with putting things on a client's screen with that.
client/verb
add()
var/obj/O = new
O.screen_loc = "3,3"
O.icon = 'test.dmi'
screen += O
remove()
for(var/obj/O in screen)
del(O)

There is a quick example if you need a jump start.

Once you understand how to utilize the client's screen list (or if you already knew), the rest is just fancy manipulation of what you can already do.
obj/text
//All characters in this example are going to be of this type
//This object type will keep track of character data
//This specific example doesn't have much to keep track of, but many text systems will require more
icon = 'text.dmi'
New(x, y, character, client/C)
/* I prefer to put everything in if statements in this way
because it is often useful to define subtypes of /obj/text
that have default values instead of getting them from New() */

if(x&&y)
screen_loc = "[x],[y]"
if(character)
icon_state = "character"
if(C)
C.screen += src
client
proc
mapCharacter(x, y, character)
new /obj/text(x, y, character, src)
mapText(text)
// This is the main part
var
x = 1 // You need counters to keep track of where on the screen the next letter goes
y = view*2 + 1
T // This will be set to each specific character in the text string in order
for(var/index = 1 to length(text))
// We need to loop around until we get to the end of the text, setting T to each character in turn
T = copytext(text, index, index+1)

// and then make an object to represent the character
mapCharacter(x, y, T)

// This next section is just to manage the counters that keep track of where to place the object
// Keep looping from 1 to view*2+1 along the x-axis, and decrementing y each time, stopping when y is at the bottom
x += 1
if(x > view*2 + 1)
x = 1
y -= 1
if(!y)
return
clearText()
// And this one just obviously clears the screen
for(var/obj/text/O in screen)
del(O)

That is about the most basic way to get text on the map. Everything else you might want to do is just going to be a derivation of it.

As for backgrounds, the process is similar. Just loop back and forth through the coordinates of a rectangle and create a new object for each coordinate, but just set the icon to the appropriate background image instead of a letter.
In response to Loduwijk
Thanks for the help ^_^