ID:178143
 
I need an efficient way to change icon_states for each different item that can be equiped, for example this is my code:
obj
weapon
Psion_energy_rod
icon = 'weapons.dmi'
icon_state = "rod_blue"//disregard this icon_state
var/Equiped = 0//if 1 item is equiped...
if (src.Equiped = 1)
if (usr.icon_state = "blonde")
usr.icon_state = "blonde_rod_blue"
if (usr.icon_state = "black")
usr.icon_state = "black_rod_blue"

and so on, very space-consuming and inefficient. This must also be written again for each item, and if my character has armor equiped along with the item, then I must write this again for each possible combination. What I need is something like:
var/weapon_state = usr.icon_state+"_rod_blue"
if (Equiped = 1)
usr.icon_state = weapon_state

or something along those lines would be great. That way I could have armor equiping act the same way, and just have 2 exact duplicate icon states for each combination, like:
icon_states:

"blonde_rod_blue_robe" and "blonde_robe_rod_blue"
would be the exact same, only serving different
orderings of equiping. I can't bang out a decent system for this though as the above doesn't work. Can someone tell me why or what else I might be able to do?
Thanks guys, Vercingatorix



One way would be to have vars such as armor, shirt, pants, hair, etc. Then, have icon_state be "[src.armor]_[src.shirt]_[src.pants]_[src.hair]"

Or you could use overlays, which would work better. I haven't used them before, so ask someone else about them.

[edit]

Or, you can look up overlays by pressing F1 in DM
In response to Garthor
Hey thanks, that just opened a few doors. Also, if you aren't too busy, could you help me with an enter verb for doors, it seems like it would be very simple but I am stumped. I am having lots of trouble in the world-to-world area. I read the guide's portion on it a couple times and I think I read some stuff here but I can't remember where.
Thanks again, Vercingatorix
In response to Vercingatorix
Im Still a Newbie Myself but i think this will solve the Door thingy,just Change it Into a Verb Process since i like Using click,and if you want it to only be able to open when your next to it set an oview.
turf/Door
icon = 'Turfs.dmi'
icon_state = "Door"
density = 1
Click()
icon_state = "DoorOpen"
density = 0
sleep(15)
icon_state = "Door"
density =1
..()