Locking and unlocking....

Though I have already authored a game, and I should already know the answer to this, but …
Is there a way to create something that is lockable (and unlockable) without having to have a key to un/lock it? Such as windows, interior doors, front doors with bolts, etc. I have a ‘way’ to do it, such as a window with catches on it, where if the catches are pulled, the window is ‘unlocked’ so you can open it(and if they are pushed, the window is again ‘locked’)–with the appropriate check rules. Unfortunately, the player would not be able to say ‘unlock window’ or ‘lock window’ without getting a generic message(because the window is not, in fact, ‘lockable’ in the strict sense, with matching key). I have considered creating a ‘master key’ and making it a part of the player, just so that it would be in his possession when encountering such doors and windows, but would that not get a response like “(with the master key) You unlock the window.”??


Would it not be easier to do something like

[code]The window can be blocked or unblocked. The window is usually blocked. The latch is a part of the window.

After pulling the latch:
if the window is unblocked:
now the window is blocked;
say “The window is now locked in place.”;
now the window is unblocked;
say “You unlock the window. It’s now openable!”;

Before opening the window:
if the window is blocked:
say “You’d need to pull the latch first.”;
stop the action;
continue the action;

Of course, this might get clunky very quickly…

I hope this helps!

There’s a built-in extension called Locksmith by Emily Short, which adds this capability. Check its documentation for a few different ways to accomplish this. (If you want to use your system of pushable catches, for instance, just include the extension and use the actions “bolting” and “unbolting”. These match commands like “un/lock window” with no key specified.)

Note that you do not need to create a new property to use Pergrine’s solution. It works just as well using “locked” and “unlocked”.

[code]The window is lockable and locked. The latch is a part of the window.

After pulling the latch:
if the window is unlocked:
now the window is locked;
say “The window is now locked.”;
now the window is unlocked;
say “You unlock the window. It’s now openable!”;

This way you don’t have to create a separate rule to handle opening or closing the window; you can let Inform’s built-in rules handle it.

Thank you all–
I wanted the player to be able to actually say ‘Unlock the window’ or ‘lock the window’, and that would be substituted by an Instead rule getting the player to pull/push the catches, whereupon the window’s locked status would change. Inform does not seem to permit this without a key. I may just have to resort to Locksmith, or see how it works.

It sounds like what you really want is a new action for keyless unlocking. Example 24 of the documentation deals with this.

Sounds like all I have to do is to re-create the command “lock/unlock”–I thought I had tried that before and it failed, so maybe I am mistaken. Thanks.

No, you need to create a new ‘keyless locking’ and ‘keyless unlocking’ action, and then set it to accept the syntax “lock something” and “unlock something”. Example 24 should set you on the straight path.

Precisely what I meant(I did read the example). Thanks