ID:140138
 
Code:
obj
Items
Armor/Head
Cyborg_Helm
icon='Armor.dmi'
icon_state="Cyborg1"
desc="A helmet from the future made of unknown metal stronger than!"
def=100
iconadd = 1//has no use yet

obj
Items
Armor/Head
verb
wear()
set src in usr.contents//in inventory
if(usr.hequipped==1)//if head slot is filled
usr<<"You already have a helmet equipped!"
else
usr.overlays += src.icon//yes i know i don't need to add src i just do it out of old habit
usr.overlays += src.icon_state
usr.def+=src.def
usr.hequipped=1//fill head slot
//please understand this is just a rough mix of what i'm trying to do
//not ment to be good and usable for a game just getting used to overlays


Problem description:
Alright i'm coding for the first time in about 2 years so i'm really rusty, but i just read the DM guide trying to re-learn. To me this makes no sense, problem is that this used to work till i changed the icon state in the .dmi file, but even after updating it in the .dm file it wont add the overlay when i try to wear it but the object has the correct icon, but if i switch the icon state back to the old one in the .dm file and not in the .dmi file the obj has no icon but it adds the correct overlay.
You are adding two things to overlays: the icon and the icon_state. For the icon, its icon_state will default to the player's icon_state. For the icon_state, its icon will default to the player's icon.

Presumably, you want to be adding src to overlays instead.
In response to Garthor
so if i understand what your saying you mean this.
obj
Items
Armor/Head
verb
wear()
set src in usr.contents//in inventory
if(usr.hequipped==1)//if head slot is filled
usr<<"You already have a helmet equipped!"
else
usr.overlays += src
usr.def+=src.def
usr.hequipped=1//fill head slot

because if you are i've tryed that before and it still does not add an overlay
In response to Scarymonkeys623
That is because the layer of the object is not set properly. By default, it will be lower than the mob layer and therefore show up behind the player.
In response to Garthor
Garthor wrote:
That is because the layer of the object is not set properly. By default, it will be lower than the mob layer and therefore show up behind the player.

so your saying i should do something like this?

obj
Items
Armor/Head
Cyborg_Helm
icon='Armor.dmi'
icon_state="Cyborg1"
desc="A helmet from the future made of unknown metal stronger than!"
def=100
layer = MOB_LAYER+1 //overhead
verb
wear()
set src in usr.contents//in inventory
if(usr.hequipped==1)//if head slot is filled
usr<<"You already have a helmet equipped!"
else
usr.overlays += src
usr.def+=def
usr.hequipped=1//fill head slot