Some Newbie Questions


I’m just getting into Inform 7, and I ran into a few problems. Apologies if these are silly questions, but I’ve checked the manual to no avail.

#1 - I have the player locked in a room, with a normal locked door, and a boarded up window (that needs to be ‘unlocked’). Now, I’d like to try and include some new commands so that the player doesn’t have to use a crowbar to unlock a bunch of planks nailed to the window frame. So I thought:

Understand “break [a locked door] with [something]” or “use [something] on [a locked door]” as unlocking

would work, but the program says no. I even tried to simplify it to - Understand “break [something]” as unlocking - but no joy. The error I usually get is

Any help with my syntax or theory would be greatly appreciated. I just know I’m missing something simple.

#2 - I’d like to change the description of an object in the game so that it’s different after the player first looks at it. For example, roaches scuttling away when a drawer is open for the first time. I know for rooms I can use [if unvisited][end if], but something like [if not examined][end if] didn’t work.

#3 - Is there a way to give two objects the same use? Back to the crowbar example, I want the player to be able to use the crowbar to either pry off the planks over the window, or smash open the door. The problem is that there’s a key that also opens the door (and gives more points if used instead), but when I try to compile I get this:

Anyway around this?

#4 - Last one, I promise (today). It’s similar to #1 (I get the same error message). I have a closet (enterable container), and a closet door (a part of the closet, openable container, not enterable). Now when the starting room comes up, it lists the closet (closed), but not the closet door because it hasn’t been looked at yet. So I figure the first command a player might use would be ‘open closet’, which they can’t because I made it so that you have to open the door first. My question is, is there a way to have Inform understand that I want open/close the closet to be the same as open/close the closet door? I tried - Understand “open the closet” as opening the closet door - but that wasn’t correct.

Again, any help would be greatly appreciated. Thanks in advance!

“Unlocking” is really “unlocking it with”. Since this action takes two nouns, Inform need some way to know where to put the noun and the second noun (the noun replaces “it” and the second noun is put last).


Understand "break [a locked door] with [something]" as unlocking it with.

ought to work.

For the second command for that action you need to do it a little differently

Understand "use [something] on [a locked door]" as unlocking it with (with nouns reversed).

The reason being that in the command the nouns are given in the reversed order compared with that of the action: “use CROWBAR on DOOR” as opposed to “unlock DOOR with CROWBAR”.

One way:

The description of the gizmo is "[if we have examined the item described]It looks vaguely familiar.[otherwise]You never saw this thing before in your life."

“Item described” can be used inside a text property (such as the “description” text property) to refer to the object that that property belongs to. (Here you could equally well write “[if we have examined the gizmo]”.)

Another way:

The description of the gizmo is "[one of]You never saw this thing before in your life[or]It looks vaguely familiar[stopping]."

The first alternative will be chosen the first time the description is printed, and the second alternative every time after that. (See Chapter 5. 7 “Text with random alternatives”)

#3 “The key unlocks the door” is kind of a special case – it sets the door’s property “matching key,” and a door can only have one matching key. So your code is throwing an error because I7 thinks (correctly) that you’re trying to set the door’s matching key property to two separate things.

This code shows how you can have an extra matching key.

BUT in this case you don’t want to have the crowbar just unlock the door – for one thing, after you unlock it with the crowbar, you can’t lock it again, certainly not with the crowbar. So you probably want to have your “Instead of unlocking the door with the crowbar” rule print something like “You smash the door open with the crowbar. It is now unlocked and will stay that way.” And then declare "Now the door is unlocked. Now the door is open. Now the door is not lockable."or something like that (haven’t checked the exact syntax).

Another point – if “Break door with crowbar” works, make sure you write a special error message for attacking the door, saying “You’ll have to say what you want to break the door with” or something like that. Otherwise, since “break” is a synonym for “attack,” the game will tell the player “violence isn’t the answer to this one” – which is misleading, when the answer is to “break” the door with a different syntax.

#4: Try “Instead of opening the closet: try opening the closet door.”

With regard to #2, the way I sometimes do it is:

The description of the whoozeewhatchamacallit is "It is red, green and purple, with an orange whatchamawhoozit in the middle.".

After examining the whoozeewhatchamacallit the first time:
     Now the description of the whoozeewhatchamacallit is "It looks the same as it did the last time you looked at it.".

Robert Rothman

Matt has a good point. There’s a number of different ways a player might try, and you want to make sure to catch as many as you can.

My instinct would be to create an “attacking it with” action, and redirect unlocking it with to attacking it with. You can take advantage of the many synonyms for attack with just one line:

[code]Attacking it with is an action applying to one thing and one carried thing.

Understand “attack [something] with/using [something]” as attacking it with.[/code]

One more warning. Any time you write an “understand” line that takes a noun token other than [something], you run the risk that players will get the error “That noun did not make sense in this context” when they use the same grammar with a different object. Make sure you also add an Understand line that takes a more general token, even if it’s an “…as a mistake” line.

Sometimes it’s better to write the grammar more generally, and use “Does the player mean…” to rule out ambiguities later.

Thank you all very much. Those suggestions fixed all of my issues. Now it’s time to mess around some more and come up with new issues…

I forgot to mention, in relation to command grammars that require specific tokens:

Before you create a “use” command, consider whether you want to implement it for every object in the game. It is quite acceptable for authors to avoid “use,” because it means a different thing for each object, and can set the player up for a letdown by giving the impression that the parser is more powerful than it really is.

You could argue either way about whether it prevents “guess-the-verb” puzzles or makes puzzles “too easy” (i.e. use means “do what the author intended” instead of something that the player thought of)… but you should have your arguments ready either way.