Swapping clothes

I think this will be much easier if, instead of making different types of wearable objects, you make body parts a kind of value and give every piece of clothing a body part that it covers. Then you can check very easily whether the player is already wearing something that covers that body part.

So something like this (untested):

Body part is a kind of value. The body parts are head, torso, legs, feet, and hands. A vestment is a kind of thing. A vestment is always wearable. [didn't use "clothing" because "a clothing" sounds funny.] A vestment has a body part called its covering. Collision relates a vestment (called X) to a vestment (called Y) when the covering of X is the covering of Y. The verb to collide with means the collision relation. Check wearing something when the player is wearing something that collides with the noun: say "You're already wearing something on your [covering of the noun]." instead. A hat is a kind of vestment. The covering of a hat is always head. A shirt is a kind of vestment. The covering of a shirt is always torso.

…and so on. If you want some more complicated stuff (e.g., pants over underpants, dresses covering torso and legs) you can look at the example “What Not To Wear” in the documentation, and more discussion here and here. And if you really want to get the type of an object we were coincidentally just discussing that and you could use loxlie’s brief I6 solution.

(Whoops, this doesn’t have the auto-remove functionality you want. Well, you can just get the vestment that’s colliding with the noun, print “(first taking off the doohickey),” try taking it off, and stop the action if the player still wears it–this is a bit more robust than just moving it to the player in case there’s something the player isn’t supposed to be able to take off like the cursed headband, or a message you want to print when they take something off, or something like that.)