Inform 7 Home Page / Documentation


§17.2. New commands for old grammar

In the photography example, we are providing entirely new grammar for an action not ordinarily built in to Inform. But we often want simply to provide alternative grammar for existing actions, or even to put new interpretations on commands that Inform already recognises. For instance:

Understand "deposit [something] in [an open container]" as inserting it into.

The inserting action is built in to Inform, but the command "deposit" is not, so this is created as new. It is occasionally useful to put a twist on this:

Understand "fill [an open container] with [something]" as inserting it into (with nouns reversed).

The clause "(with nouns reversed)" tells Inform to exchange the two nouns parsed, which is necessary because the inserting action expects the noun to be the item and the second noun to be the container, not vice versa.

The following example:

Understand "access [something]" as opening.

might look as if it makes "access" behave just like "open" when the player types it, but that's not so: "open" can also be used in constructions like "open the door with the brass key", in which case it is understood as the unlocking action. We could add another line to make "access" behave this way too, but if what we really want is to make "access" behave just like "open", it's easier simply to say so:

Understand the command "access" as "open".

This is very useful when adding a new command which needs synonyms:

Understand the commands "snap" and "picture" as "photograph".

We can check the current stock of commands by looking at the table in the Actions index: for instance, before making "snap" synonymous with "photograph", it might be wise to check that it is not already defined as a command for breaking something.


arrow-up.png Start of Chapter 17: Understanding
arrow-left.png Back to §17.1. Understand
arrow-right.png Onward to §17.3. Overriding existing commands

*ExampleAlpaca Farm
A generic USE action which behaves sensibly with a range of different objects.

*ExampleAnchorite
By default, Inform understands GET OFF, GET UP, or GET OUT when the player is sitting or standing on an enterable object. We might also want to add GET DOWN and DOWN as exit commands, though.

****ExampleCloak of Darkness
Implementation of "Cloak of Darkness", a simple example game that for years has been used to demonstrate the features of IF languages.