ID:144761
 
Code:
var
obj
hud
Hide
A = new() //Defines the HUD
usr.client.screen += A //Adds the HUD

obj/hud/Hide
icon='Hide.dmi'
screen_loc="1,1"
Click(Hide())
if(usr.it)
return
if(get_dist(src,usr) <= 1&&get_step(src,EAST)==usr.dir)
set src in oview(1)
if(usr.it)
return
else if(usr.frozen)
return
else if(Notplayer==0)
return
else
usr.loc=locate(src.x,src.y,src.z)
usr.layer=4


That is my code for my HUD button but it says that usr.client.screen is an undefined Var. Any Ideas?

1) "usr" was never defined, especially when variables are compiled... you need to modify it.. such as:
In response to GhostAnime
there was no code, but i guess i'll try to define usr
In response to KirbyAllStar
Sorry, post got posted before I finished it:


1) "usr" was never defined, especially when variables are compiled... you need to modify it.. such as:
Hide
New(client/M) M.screen+=src


In this example, you can have something like this:
mob/Login()
..()
if(src.client)new/HUD/Hide(client)


This would call the New() proc in HUD/Hide and do whatever it says, which is placing the object into the client.screen.. ofcourse you couldve just done new/HUD/Hide(src.client.screen) and avoided the whole New() thing...

2) "Click(Hide())" <-- Hide() is useless there, get rid of it... and look up Click() in the reference... If you wish the HUD, when clicked, to call the verb Hide, you could've saved time by:
Click() Hide()

and the verb would do the rest [meaning ignore the following points]

3) "if(get_dist(src,usr) <= 1&&get_step(src,EAST)==usr.dir)" <-- If it's in the client.scren (the HUD), this line is absolutely worthless. Why? src refers to the object itself

4) "set src in oview(1)" <-- This is a procedure, not a verb, hence this line is... USELESS :O!

- GhostAnime
In response to GhostAnime
mob
proc/Hide()
if(get_dist(src,usr) <= 1&&get_dir(usr,src)==usr.dir)
set src in oview(1)
if(usr.it)
return
else if(usr.frozen)
return
else if(Notplayer==0)
return
else
usr.loc=locate(src.x,src.y,src.z)
usr.layer=4
var
obj
hud
Hide
New(mob/A) A.client.screen+=src
A = new() //Defines the HUD
usr.client.screen += A //Adds the HUD

obj/hud/Hide/A
icon='Hide.dmi'
screen_loc="1,1"
Click()
Hide()


This is what I have now but it still has errors. not sure if this is what you meant
In response to KirbyAllStar
Um, sorry for not being too clear, I suffer from egocentricism :P (Which I doubt is a real problem/word anyways)

It is not wise to use usr in proc... and based on your proc, it's useless... usr (if used correctly) & src are one and the same... again, refering to "if(get_dist(src,usr) <= 1&&get_dir(usr,src)==usr.dir)"... I have no idea what this is suppose to be used for anyways

obj
hud
Hide
New(mob/A) A.client.screen+=src
That is all I meant to show you, no var before obj and nothing after New() as there's only 1 line effecting it

Take away the /A from "obj/hud/Hide/A" and you got it down :)

If you don't understand something, ask... it won't hurt... much

- GhostAnime