ID:159276
 
I'm trying to create a hud but idk what to do whay i have coded in it this

obj
hud
icon='turf.dmi'
icon_state="grass"
screen_loc="2,2"
layer= MOB_LAYER+1

can you show me how... like whats the coding for it?
So far i see nothing that speaks of making a hud >_>
In response to Kryu
you need to add the hud object to the users client screen.

this is done by :

usr.client.screen += new/obj/hud


If you add this code to your character creation or wherever you feel for it, the hud will show on the screen.

im sure there are other, better ways to do this. but this is the way that i used.

example:

obj
hud
name = "hud"
icon = 'hud.dmi'
icon_state = "hud1"
screen_loc = "1,4"
layer = MOB_LAYER+100
//above is the hud example
//below is the character creation example

client
proc
create_character()
var/mob/newmob
switch(input("What race would you like to be?","race")in list("Human")
if("Human")
newmob.race = "Human"
newmob.str = 5
newmob.def = 5
newmob.atk = 5
newmob.client.screen += new/obj/hud // this will add the hud to the users client screen.


Hope this helps
obj
hud
icon='turf.dmi'
icon_state="grass"
screen_loc="2,2"
layer= MOB_LAYER+1

HMmmm
Nomatter what the layer is if u want to put this in the hud just put as this
obj
hud
icon='turf.dmi'
icon_state="grass"
screen_loc="2,2"
New(mob/M)
screen_loc="2,2"
M.client_screen+=src

correct me I may be wrong
In response to Getenks
Be careful when messing around with atom/New(). (In this case obj/New()) The first variable should always be the location. In this case, that may lead to something unexpected, like the HUB item appearing in the inventory.
If you're going to change New() like that, I'd define it as
obj
hud
icon='turf.dmi'
icon_state="grass"
screen_loc="2,2"
New(loc,mob/M)
screen_loc="2,2"
M.client_screen+=src


I may be wrong too, but it's given me trouble in the past.
In response to Zeppo
you could also do it like this

client/New()
new /obj/Say(src)//Creates the Say Hud
..() // Continues with the script (used for not getting a connection died)

obj/Say//The actual Say Hud
icon = 'Hud.dmi'
icon_state = "Say Button"
screen_loc = "2,1"//Tells where the XY are
Click()//When you click it, it does its action..
usr<<"You have clicked on the Say Button!"
// /\ Wow you clicked the Hud Button!
New(client/C)
C.screen+=src//Add it to your screen


this is a demo by flame sage
In response to Chessmaster_19
Chessmaster_19 wrote:
Be careful when messing around with atom/New(). (In this case obj/New()) The first variable should always be the location. In this case, that may lead to something unexpected, like the HU<s>B</s>D item appearing in the inventory.

You're correct. With atoms, new() will automatically put the object in the first argument - it's used for the object's location, so if you put a mob there, the object will end up inside the mob's contents. Most people just directly use the client instead as the mob isn't needed, and if you pass something that isn't a location (like a client) as the first argument, it won't put the object anywhere and will essentially do nothing in that regard.
In response to Kaioken
Hmmmmm...
Gotcha