ID:139561
 
I've had a problem with an HUD before that had worked up until now for some reason:
obj/Wright
icon = 'Phoenix Wright Table Slam.dmi'
icon_state = ""
layer = 999
New(client/c)
screen_loc="10,5"
c.screen+=src
Del(client/c)
c.screen-=src
mob/proc
Wright()
src << sound(null)
src << sound('Investigation ~ Cornered 2004 Remix.mid')
sleep(10)
var/obj/Wright/W = new/obj/Wright
W.icon_state = "1"


runtime error: Cannot read null.screen
proc name: New (/obj/Wright/New)

I have also tried:

obj/Wright
icon = 'Phoenix Wright Table Slam.dmi'
icon_state = ""
layer = 999
New(client/c)
screen_loc="10,5"
c.screen+=src
Del(client/c)
c.screen-=src
obj/var
screen
mob/proc
Wright()
src << sound(null)
src << sound('Investigation ~ Cornered 2004 Remix.mid')
sleep(10)
var/obj/Wright/W = new/obj/Wright
W.icon_state = "1"

And got a different runtime error, but no errors on the compiler.

What I need to know is what is wrong with it. I do not need any "spoon feeding". I recall on another post I wished for an explanation, not a string of code and got trolled by almost everyone saying I want to be spoon fed.
Replace <small>var/obj/Wright/W = new/obj/Wright</small> with <small>src.client.screen += new/obj/Wright</small> and set its icon state somewhere else like the <small>New()</small> proc.
In response to DarkeWarrior
DarkeWarrior wrote:
Replace <small>var/obj/Wright/W = new/obj/Wright</small> with <small>src.client.screen += new/obj/Wright</small> and set its icon state somewhere else like the <small>New()</small> proc.

Sorry, but the only issue with that is, I want it's icon state to constantly change. I also want it set to a variable, which requires the var/obj/Wright/W in it, doesn't it?
In response to Narutorox123456
Not necessarily. If you ever wanted to change it's icon state at any given time you could simply use <small>for(var/obj/Wright/w in client.screen)</small>
In response to DarkeWarrior
DarkeWarrior wrote:
Not necessarily. If you ever wanted to change it's icon state at any given time you could simply use <small>for(var/obj/Wright/w in client.screen)</small>

Oh, Ok. I didn't realize that! I'm going to re-do the code to fit your description the best I can and tell you if I get any errors or runtime errors!
In response to DarkeWarrior
DarkeWarrior wrote:
Not necessarily. If you ever wanted to change it's icon state at any given time you could simply use <small>for(var/obj/Wright/w in client.screen)</small>

Ok, so far it is doing good and is showing up. The only problem: It gives a runtime error:

runtime error: Cannot read null.screen
proc name: New (/obj/Wright/New)
In response to Narutorox123456
Instead of <small>client.screen += new/obj/Wright</small>, try <small>var/obj/Wright/W = new(src.client)</small>. Condolences to Calus CoRPS for pointing that out.
In response to DarkeWarrior
DarkeWarrior wrote:
Instead of <small>client.screen += new/obj/Wright</small>, try <small>var/obj/Wright/W = new(src.client)</small>. Condolences to Calus CoRPS for pointing that out.

Thanks! It works fine now!