Chapter 11: Phrases
11.7. Begin and end

In practice it is not enough to apply "if" to a single phrase alone: we want to give a whole list of phrases to be followed repeatedly, or to be followed only if a condition holds.

We do this by grouping them together, and there are two ways to do this. One is as follows:

To comment upon (whatever - a thing):
    if whatever is transparent, say "I see right through this!";
    if whatever is an open door:
        say "Oh look, an open door!";
        if whatever is openable, say "But you could always shut it."

Here we group two phrases together under the same "if". Note that the "then" has been replaced by a colon, and that the indentation in the list of phrases shows how they are grouped together. In the example above, the source moves two tabs in from the margin; the maximum allowed is 25.

Indentation is the convention used in this manual and in the examples, but not everybody likes this Pythonesque syntax. So Inform also recognises a more explicit form, in which the beginning and ending are marked with the words "begin" and "end":

To comment upon (whatever - a thing):
    if whatever is transparent, say "I see right through this!";
    if whatever is an open door
    begin;
        say "Oh look, an open door!";
        if whatever is openable, say "But you could always shut it.";
    end if.

(Pythonesque because it's a style popularised by the programming language Python, named in turn after "Monty Python's Flying Circus".)


172
* Example  Princess and the Pea
The player is unable to sleep on a mattress (or stack of mattresses) because the bottom one has something uncomfortable under it.

RB
173
* Example  Matreshka
A SEARCH [room] action that will open every container the player can see, stopping only when there don't remain any that are closed, unlocked, and openable.

RB

"Matreshka"

Ransacking is an action applying to one thing.

Check ransacking:
    if the noun is not the location, say "You can hardly search [the noun] from here." instead.

Carry out ransacking:
    while the player can see a closed openable unlocked container (called target):
        say "[target]: [run paragraph on]";
        try opening the target.

Report ransacking:
    say "You can see nothing further worth searching."

The Russian Gift Shop is a room. In the Russian Gift Shop is a large wooden doll. It is closed and openable. In the large wooden doll is a medium wooden doll. It is closed and openable. In the medium wooden doll is a small wooden doll. It is closed and openable. In the small wooden doll is a tiny solid wooden doll.

And now we need to borrow from a later chapter for the command that will make this work:

Understand "search [any visited room]" as ransacking.

Test me with "search gift shop".


PreviousContentsNext