If the door is unlocked

Hello everyone

I can’t work out why this isn’t working in Inform…

instead of opening the Music Room Door if the door is unlocked:
	end the story saying "Congratulations you escaped. Have a great summer!"

The door exists and is locked and the code works until i add the line

if the door is unlocked

any ideas? Thanks for the help as always!!

You need when instead of if in rule preambles.

It’s automatically enforced that you can’t open a locked door, so you don’t even need that test. This could be just:

After opening the Music Room door, end the story saying "Congratulations you escaped. Have a great summer!"


A very specific answer is that the entire name of the door must be in the rule, and that “when” rather than “if” is required in preambles.

instead of opening the Music Room Door when the music room door is unlocked:

also, Inform will automatically handle locked… [looks up], oh, I see that’s been covered. :smiley_cat:


A shorthand for this is the noun since the rule is triggered from the player’s command.

The command that triggers this rule will be some form of “open [music room] door” so the noun is the door.

Instead of opening the Music Room door when the noun is unlocked;

It means the same thing, but doesn’t feel as “department of redundancy department” to write.


I prefer seeing it again, as a matter of taste! But it is kind of Inform to afford so many paths to the same, er, door :smiley_cat:


It’s also useful when you write a more general rule where you’re not sure which noun is affected.

[Say you have a room with a Red Door, a Blue Door, and a Green Door, all sentient…]

Before opening a door in the Room of Talking Doors when the noun is locked:
     say "'YOU MUST SAY THE MAGIC WORD TO UNLOCK ME!' bellows [the noun]." instead.

That way you don’t have to write the rule three times.


You can also just combine the adjective and noun.

Instead of opening the unlocked music room door...

The important thing, though, is that Inform generally doesn’t have enough knowledge of context to figure out what “the” means. Usually you only want to use “the” when the words after it are absolutely unambiguous. “The music room door” is fine, since there’s only one music room door. But “the door” is not—there could be a lot of doors out there!

Fortunately, Inform also gives us various ways of assigning unique names to things.

Before opening an unlocked door (called the door in question):

Now “the door in question” is unambiguous, since there’s only one door currently being opened.

1 Like

I had something similar to this to start with…

I’m using this as part of an escape room. Participants are locked in the same room that is being described in Inform and so can use things in the real space and the virtual one

I’m using magic to unlock the door…

Performing magic is an action applying to nothing.

understand "b major" as performing magic.
understand "bmajor" as performing magic.

after performing magic:
	now the Music Room Door is unlocked;
	say "You hear the click of a lock..have you done it?";

Somehow when I added this line my locked door no longer worked and the first participants escaped simply by typing “open the door” :upside_down_face: :pensive:

instead of opening the Music Room Door:
	end the story saying "Congratulations you escaped. Have a great summer!"

Yes I tried putting in the full door name but that didn’t fix the issue.

1 Like

how about “when” instead of “if?”


Just trying that now :+1:

1 Like

That’s an Instead rule working as intended – they cut off most of the usual action processing, such as the check rules that prevent you from opening a locked door (this is one of the reasons folks warn newer authors against over-using Instead rules!) You probably want to make this a carry out rule.


Yes, this is a classic case of being thwarted by an Instead rule. Instead of opening the door [whether it’s locked or unlocked or whatever]…do this.

Probably best practice, it should be:

After opening the Music Room Door [After only occurs if the action is successful]:
     end the story saying...

That way you don’t have to test if the door is locked. If it’s locked and not opened, the After rule won’t fire.


Yeah I get lost in the “carry out” rules ha ha… you won’t believe how much of this build is relying on ‘mistakes’…

understand "ask [someone][text]" as a mistake ("[one of]'I'm just an NPC...I don't know anything!'
1 Like

Yeah I just needed “when” :upside_down_face:

That and being specific about which door…winning combo!

Thanks everyone. I always appreciate the responses on here!


Ideally, you wouldn’t create a mistake rule about ask/tell if you’re using it in the game elsewhere.

Last report asking someone about (this is the I dunno rule):
     say "I dunno, I'm just an NPC."

^^That becomes the default rule. Every character will respond this way unless there’s another rule that intercedes. Inform 7 will always choose to follow a more specific rule first, so then you write:

Report asking Bob about the wallet:
     say "I dunno, it's my wallet.";
     stop the action. 

[Report rules continue so there can be several, you want to stop after this one so the generic “I dunno” rule won’t run]


After asking Bob about the wallet: 
     say "I dunno, it's my wallet.";

[After rules run before Report and by default stop the action]


Yes a lot about this build is not what you’d call ‘good practise’.

Thankfully it’s only one room and there’s only one NPC!

I have tried a few times to approach conversation and it’s never been very successful. In the end I resort to ‘mistakes’ to plug all the holes in the build…

Thanks for the help…I’ll play around with ;report’ and see what happens :grinning:

Seriously, if you want to add conversation in and not futz with it much, use Eric Eve’s “Conversation Responses”.

If it’s not a game where you want to use ask/tell, the mistake rule is perfectly legit, although I think a mistake rule does not increment the time/turn count - it registers as the player typing something like OPEN BOULDER “You can’t open that” and doesn’t advance time. Depends whether you want idle conversation to count as a turn or not.

1 Like

extensions…something else I’ve never successfully implemented :sweat_smile:

I tend to have something like this as standard:

Understand "who" or "what" or "when" or "where" or "why" or "how" or "who's" or "what's" or "when's" or "where's" or "why's" or "how's" or "whats" or "whens" or "wheres" or "whys" or "hows" or "help" as "[query]".

Understand "[query] [text]" as a mistake ("[bold type]Try typing these actions[paragraph break]Look at[roman type] (item) - for more information about an object[paragraph break][Bold Type]Talk to [roman type](character)[paragraph break][bold type]Take/drop [roman type](item").

I then just started using ‘mistakes’ to do anything I couldn’t figure the code out for… :upside_down_face: