ID:145931
 
Code:
if(usr.overlays== /obj/sword)
usr.overlays -= /obj/sword_control
usr.overlays += /obj/sword_control


Problem description:
why it dont delete overlays and put new ones?

That if() statement seems useless as hell...
In response to Mysame
? what you mean?
just now only one wep. it should add diferent overlay for differend wep if it worn ! then how to make ?
User overlays are not going to equal one item, so you have to check if that item would be in your overlays. Like so:
if(locate(/obj/Sword/) in src.overlays)

Then, you wanted to delete an overlay and add a new one. This seems so useless because you check for a sword in your overlays and if it's there, you take another overlay away and add the same type of the overlay you have taken away. But, here goes.
    if(locate(/obj/Sword/) in src.overlays)
src.overlays.Remove(locate(/obj/sword_control/) in src.overlays)
sleep(10) //so you can see that it has removed it
src.overlays.Add(new/obj/sword_control/)
In response to CaptFalcon33035
dont work. someting with
if(locate(/obj/sword/) in src.overlays)
In response to Ripiz
Meaning, you gotta show us more code. Show us the entire porc and the weapons you are dealing with.
In response to CaptFalcon33035
mob
verb
Spirit_Control()
switch(alert("Spirit Control on/off?","Spirit Control","On","Off"))
if("On")
if(usr.fury==1)
usr << "You already use Spirit Control."
else
usr.fury = 1
view(6) << "[usr]:<FONT SIZE=-1><font color = teal>[usr.spirit]! Spirit Control!"
flick("fuse",usr)
usr.attack += (usr.spirit_attack+src.attack_up*2)
usr.defense += usr.spirit_defense
if(locate(/obj/sword/) in src.overlays)
src.overlays.Remove(locate(/obj/sword/) in src.overlays)
sleep(10) //so you can see that it has removed it
src.overlays.Add(new/obj/sword_control/)

obj
sword
icon = 'weapons.dmi'
icon_state = "sword"
sword_control
icon = 'weapons.dmi'
icon_state = "sword_control"
In response to Ripiz
Okay, first off, you shouldn't be checking to see if fury is one, because it seems to be a boolean variable. Just use if(src.fury).

Now, you still haven't told me exactly why you're trying to remove sword_control, then add it if there is a sword. I think you might want to add it, then remove it.

mob/verb/Spririt_Control()
switch(alert("Spirit Control on/off?","Spirit Control","On","Off"))
if("On")
if(src.fury) src<<"You are furious already!"
else
src.fury=TRUE
view(6) << "[usr]:<FONT SIZE=-1><font color = teal>[usr.spirit]! Spirit Control!"
flick("fuse",usr)
usr.attack += (usr.spirit_attack+src.attack_up*2)
usr.defense += usr.spirit_defense
if(locate(/obj/sword/) in src.overlays)
var/obj/sword_control/T=new(src.overlays)
sleep(10)
src.overlays.Remove(T)