ID:1093585
 
Keywords: overlays
(See the best response by Jemai1.)
Code:
obj
NejiSuit
name = "Neji Suit"
icon = 'Clothes.dmi'
icon_state = "NejiSuit"
worn = 0
price = 4500
verb
Drop()
set category = null
if(src:worn == 1)
usr << "Not while its being worn."
if(src:worn == 0)
src.loc=locate(usr.x,usr.y-1,usr.z)
usr.UpdateInv()
usr.SaveK()
Get()
set category = null
set src in oview(1)
src.loc = usr
usr<<"You picked up a [src]"
usr.UpdateInv()
usr.SaveK()
Delete()
set category = null
if(src:worn == 1)
usr << "Not while its being worn."
else
del(src)
usr.SaveK()
usr.UpdateInv()
Click()
if(src.worn == 1)
src:worn = 0
usr.overlays -= 'Clothes.dmi'
usr.icon_state = "NejiSuit"
usr << "You remove the [src.name]."
src.suffix = ""
else
src:worn = 1
usr.overlays += 'Clothes.dmi'
usr.icon_state = "NejiSuit"
usr << "You wear the [src.name]."
src.suffix = "Equipped"


Problem description:
The Problem with this code is that the icon state isnt specified to a single icon within the Clothes.dmi, if i want to wear two items of clothing, it removes the first and puts the second on (im just mucking around coding with this source, learning for when i want to code properly)
i cant find how to fix this anywhere :\
i have made a few modifications to the original coding too
This is what you get when you use ripped sources.

The solution is probably to check if you're wearing something already and if so, remove it and equip the new clothes.
ugh so there is no solution, i could recode something if i knew where to start?
I gave you a solution; you could try it.
The problem is that you are changing the mob's icon_state from one to another.

To overlay a desired state within an icon file, you can make an instance of the /icon datum.
usr.overlays += new/icon('Clothes.dmi',"NejiSuit")
// However, this approach is not advised.

A better way of doing this is to use objs paths or instances.
usr.overlays += /obj/NejiSuit

See overlays for further details. The reference also introduces you to a special layer which is FLOAT_LAYER.
ah thankyou very much
for future reference, why isnt the first approach advised?
Best response
Making an icon datum will load the icon and put it into your memory. This is done so you can manipulate it later. This process is resource intensive and not needed in the current case.

The second approach is way faster.
oh sweet, its basic, but thanks for the assistance :)
okay, im following this code, and the icon is there, i think, but its appearing behind the icon even though it clearly says

usr.overlays += /obj/'object name'


can anyone tell me why this is?
In response to Knight_of_death
Objs are on a lower layer than mobs are, by default. You need to tell the obj to either be on a higher layer, or use the special FLOAT_LAYER setting.