ID:268128
 
Say i was to have an icon on the screen that would tell me how much a weapon is upgraded. So far i have;
obj/hud
axe
icon='weaphud.dmi'
if(axelevel=0)
icon_state="axe0"
if(axelevel=1)
icon_state="axe1"
if(axelevel=2)
icon_state="axe2"
if(axelevel=3)
icon_state="axe3"
if(axelevel=4)
icon_state="axe4"
if(axelevel=5)
icon_state="axe5"
if(axelevel=6)
icon_state="axe6"
if(axelevel=7)
icon_state="axe7"
New(client/C)
screen_loc = "6,13"
C.screen+=src

With each different level of axe, the picture on the hud would change depending on what level it is.

How would i do this?
You can't put if statements out in the open like that. They must be inside of a proc or verb. First you need to add the obj to a persons screen, then you call the proc that updates the obj in their screen.
In response to Jotdaniel
ok let me update the code with all the stuff that i have for it.

var
axelevel

obj/hud
axe
icon='weaphud.dmi'
if(axelevel=0)
icon_state="axe0"
if(axelevel=1)
icon_state="axe1"
if(axelevel=2)
icon_state="axe2"
if(axelevel=3)
icon_state="axe3"
if(axelevel=4)
icon_state="axe4"
if(axelevel=5)
icon_state="axe5"
if(axelevel=6)
icon_state="axe6"
if(axelevel=7)
icon_state="axe7"
New(client/C)
screen_loc = "6,13"
C.screen+=src

client/New()
..()
new/obj/hud/axe(src)

Basically, what i want it to do is change the icon state when the actual weapon has been upgraded.
In response to Evil Guy
To give you a hint of how you need to do this:
mob/proc/Upgrade(obj/O)
for(var/obj/hud/axe/O in src.client.screen)
O.axelevel+=1
O.icon_state = "axe[O.axelevel]"


This is not exactly what you need to do, but its a good example. You should look up the different parts that I used here, and understand what its doing.

In response to Jotdaniel
Don't worry, thats fine. I just needed a push in the right direction because i haven't coded for a while because i've been busy with studies ect. and it slipped my mind.

Thanks very much.

Rob