ID:2125487
 
(See the best response by Kaiochao.)
Code: To allow the user to remove the disguise, you would need to store the original icon in a variable. You could do it like this:
obj/disguise
var/old_icon
verb
wear()
old_icon = usr.icon
usr.icon = icon
remove()
usr.icon = old_icon


Problem description: I'm reading the DM Guide and in chapter 5 it describes storing a something in a var to reuse and the way they wrote the sample code has confused me. could someone elaborate a little more on how this saves the old icon as a var and assigns the new without overwriting the old?
Best response
Variables contain values, but they aren't themselves values. You can't set a variable to refer to another variable. When you set a variable to another variable, you're only setting it to the value contained by the other variable.

old_icon is a variable. It's declared under the /obj/disguise type, so all instances of that type have their own old_icon variable, similar to how different players can have different names.
After the disguise is worn, it contains the icon that the user had before wearing it.

usr.icon is a variable.
When the disguise is worn, it is assigned to the icon of the disguise itself.
When the disguise is removed (after having been worn), it is assigned to the value of old_icon: the icon that the user had before wearing it.

When old_icon is set to usr.icon, setting usr.icon does not affect the value contained by old_icon, because why would it?
ok i understand it now thanks alot it had me abit confused