Lockable clothing?

I feel like every time I try to create something, I’m trying to break an internal rule–and Inform 7 is constantly telling me I can’t do what I want it to do. For instant, shouldn’t it be possible to create a wearable thing that the player can’t remove (without a key or assistance)? I’ve tried writing, “The player is wearing a straitjacket. The straitjacket is lockable and locked.” But then Inform 7 tells me that the straightjacket cannot be lockable because only a room, thing, etc. can be lockable. But wouldn’t a straitjacket be considered a thing? Especially if I’ve taken it a step further and have already declared a straitjacket to be a jacket and a jacket to be a kind of thing?

After declaring a jacket to be a kind of thing, you can declare it to be lockable and locked:

[code]Asylum is a room.

A jacket is a kind of thing. A jacket is wearable. A jacket can be lockable. A jacket can be locked. The straitjacket is a jacket. The straitjacket is lockable and locked.

The player is wearing the straitjacket. Instead of taking off the locked straitjacket: say “You’d need the key.”[/code]

And you don’t even need to go through a kind, if you don’t want to:

[code]Asylum is a room.

The straitjacket is a thing. The straitjacket can be lockable. The straitjacket can be locked. The straitjacket is lockable and locked.

The player is wearing the straitjacket. Instead of taking off the locked straitjacket: say “You’d need the key.”[/code]

It may seem as though declaring the straitjacket to be locked and lockable should make it automatic that it can be locked and lockable, but apparently it doesn’t.

So if you don’t use a phrase such as ‘Instead of taking off the locked straitjacket: say “You’d need the key.”’, then any lockable object can be removed, opened, etc.? I think I got this all to work at some point (because all this information should be included in my clothing designations), but I was surprised that the straitjacket could be taken off despite being locked.

Nevermind, I think I’m already guessing the errors in my way of thinking, because locked and unlocked probably only refer to things that can be opened. And taking something off isn’t the same as opening something. But thank you! I think you’ve given the tools I need to make this work.

EDIT: Is there a way to tell Inform that if a garment is locked, that it cannot be removed? The reason I ask is because I’m establishing other rules that take off garments if underlying garments are removed. This means, if I take off the shirt underneath the straitjacket, the straitjacket is also removed. I want to know how to prevent this from happening.

Yes, Inform doesn’t really understand the concept that a piece of clothing is locked to your body. It’s really just containers and doors that handle locks properly. And you are allowed to carry locked containers around, they are not locked to their position, they are locked in the sense that you can’t open them.

Try this on:

A garment is a kind of thing. A garment can be worn.

check taking off a garment (called G):
	if G is tethered: 
		say "You can't remove [the G], it's locked to your body.";
		stop the action.

the demo is a room. 

The jacket is a garment. The jacket can be tethered. The jacket is tethered. The player is wearing the jacket. 

the key is a thing, here.

after taking the key when the key is not handled:
	say "You unlock the jacket.";	
	now the jacket is not tethered.
test me with "remove jacket / take key / remove jacket"

You’re still going to need custom code for locking and unlocking the garment, just saying “it can be locked” is not enough - just anything that will toggle the locked property (above I called it tethered - you can call it locked, or whatever you like).

Another approach might be to make a special little container called a padlock and make it “part of the jacket” and then check to see whether the padlock is locked.

Awesome, thank you!