ID:208226
 
(See the best response by DarkCampainger.)
Code:
mob/Npc
Barber
icon='Npc.dmi'
icon_state="mirror"
DblClick()
if(src in oview(2))
switch(input("Do you want a haircut?", text) in list ("Yes","No"))
if("Yes")
usr.overlays -= new/obj/HairOver
usr.overlays -= new/obj/HairOver
var/hairred = input("How much red do you want to put into your hair?") as num
var/hairblue = input("How much blue do you want to put into your hair?") as num
var/hairgreen = input("How much green do you want to put into your hair?") as num
switch(input("What hair style would you like?", text) in list ("Style1","Style2"))
if("Style1")
var/obj/HO=new/obj/HairOver
HO.icon='Urahara.dmi'
HO.icon += rgb(hairred,hairgreen,hairblue)
usr.overlays += HO
if("Style2")
var/obj/HO=new/obj/HairOver
HO.icon='Yoruichi.dmi'
HO.icon += rgb(hairred,hairgreen,hairblue)
usr.overlays += HO


Problem description:

it wont remove the previous hairoverlay when the users try to get a new hair can someone help me with this Thank you
mob/Npc
Barber2
icon='Npc.dmi'
icon_state="base"
DblClick()
if(src in oview(2))
switch(input("Do you want a haircut?", text) in list ("Yes","No"))
if("Yes")
var/obj/HairOver/HO=new()
src.HairOver=HO
src.HairOver.layer=src.layer+2
src.overlays-=src.HairOver
var/hairred = input("How much red do you want to put into your hair?") as num
var/hairblue = input("How much blue do you want to put into your hair?") as num
var/hairgreen = input("How much green do you want to put into your hair?") as num
switch(input("What hair style would you like?", text) in list ("Style1","Style2"))
if("Style1")
HairOver.icon='Urahara.dmi'
HairOver.icon += rgb(hairred,hairgreen,hairblue)
usr.overlays += HairOver
if("Style1")
usr.overlays -= HairOver

still wont come offf
You have 2 "Style1"? Could be that, fix that and tell me how it goes.
In response to The ComEdiAn
Best response
Order is vital. You need to remove the old overlay as stored in src.HairOver before assigning it to the new one. You should be working off your temporary local variable "HO" until you're ready to apply the new overlay, and then remove HairOver from the overlays list, add HO to overlays, and set HairOver to HO.
mob/Npc
Barber2
icon='Npc.dmi'
icon_state="base"
DblClick()
if(src in oview(2))
switch(input("Do you want a haircut?", text) in list ("Yes","No"))
if("Yes")
var/obj/HairOver/HO=new()
usr.overlays-= HO
src.HairOver=HO
src.HairOver.layer=src.layer+2
var/hairred = input("How much red do you want to put into your hair?") as num
var/hairblue = input("How much blue do you want to put into your hair?") as num
var/hairgreen = input("How much green do you want to put into your hair?") as num
switch(input("What hair style would you like?", text) in list ("Style1","Style2"))
if("Style1")
HairOver.icon='Urahara.dmi'
HairOver.icon += rgb(hairred,hairgreen,hairblue)
usr.overlays += HO
if("Style1")
usr.overlays -= HO

so like this?
That doesnt work and still dont really understand
Why do you have two if("style1") under the same switch? The second will be ignored.
Is there anything alse besides hair in the overlays? If not, you could simply do overlays=list() to clear the contents before hadding the new hair.
Forgive me the horrible typos in the earlier post, I saw them after posting and for some reasons I cannot edit it :(