| Chapter 8: Change |

| 8.18. Review of Chapter 8: Change

1. Things that vary. A "variable" is a named value which changes as time goes by. In this chapter, we saw only one of the two sorts of variable: a value which exists throughout the whole game. For instance:

> The prevailing wind is a direction that varies.
> The current horse is an animal that varies.
> The last remark is some text that varies.
> The previous item is a thing that varies.

(In the chapter on Phrases we shall later see that is also possible to have named values that exist only temporarily, using the "let..." phrase.) A variable always has a kind - sometimes a kind of object, like "a direction" or "an animal" or "a thing", and sometimes a kind of value, like "some text" or "a number".

2. Change. We may change values with the "change" phrase:

> change the prevailing wind to east;
> change the current horse to Comet;

There are also several pre-defined variables that we can alter to affect the way the game appears or plays:

> change the command prompt to "And then? ";
> change the left hand status line to "[time of day]";
> change the right hand status line to "[score] / [turn count]";

and, perhaps most dramatically,

> change the player to Lord Bowler;

"Player" is in fact a player-character that varies. By default, Inform creates a "yourself" character for the player; but if, in the course of play, we would like to switch to a new protagonist, we may do so. The player's commands will then control this new player-character, wherever he or she may be. The "yourself" character will remain where it was, but no longer controlled by the player, unless we explicitly move it off-stage.

3. Changing properties. We may also change either/or and value properties of things with the "change" phrase:

> change the oaken door to closed;
> change the printed name of the Closet to "Scary Closet";
> change the brightness of the lamp to flickering;

4. Moving things around the map. We may move things (and the player) around the world with such phrases as

> move the hat to the wardrobe;
> move the player to the San Francisco;
> move the player to the Moon, printing an abbreviated room description;
> move the player to the North Hall, without printing a room description;
> remove the penny black from play;

We may also check whether something is outside the scope of the game with

> if the gold coin is off-stage, ...
> if the gold coin is on-stage, ...

A thing will be on-stage if its location is a room (that is, if Inform can find a room that directly or indirectly contains the item). Otherwise, it will be off-stage.

5. Now... The "now" phrase is even more powerful: it can do many of the same things as move and change, and a few others besides.

> now the player is in the South Corridor;
> now the player wears the hat;
> now the oaken door is closed;

It is also able to give instructions for multiple items, using descriptions:

> now all the doors are open;
> now everything in the sack is in the box;
> now every woman loved by Brisco is angry;

6. Checking locations. By default, things in Inform games relate to one another physically by

> to contain - containment relation
> to support - support relation
> to carry - carrying relation
> to wear - wearing relation
> to be part of - incorporation relation
> to be adjacent to - adjacency relation
> to have - to either carry or wear, which we call the possession relation
> to enclose - an indirect containment/support/incorporation relation
> to hold - a direct containment/support/incorporation relation

(We have met these before in the chapter on Things, and will review them further in the Relations chapter.) We may check on the state of any of these relations like so:

> if the bottle contains whiskey, ...
> if the bar supports a ten-dollar gold piece, ...
> if the player carries a six-shooter, ...
> if Daisy is wearing a corset, ...
> if the Gilded Rod is part of the Time Orb, ...
> if the location is adjacent to the Train Yard, ...
> if a bounty-hunter has a warrant, ...
> if the Saloon encloses a gun-slinger, ...
> if Daisy is holding the infant Emperor of China, ...

The "holding relation" includes containment, support, incorporation, wearing, and carrying, all in a single idea; so it is sometimes convenient to be able to talk generically about the holder of something. In the preceding examples, for instance:

> the holder of the emperor = Daisy
> the holder of the Gilded Rod = the Time Orb

7. Callings. Since the descriptions used in these conditions can be open-ended, it is sometimes useful to keep track of what specific things were found, using the "(called...)" construction. Here we check for the existence of a certain kind of bounty-hunter, and remember his name if he exists:

> if a bounty-hunter (called the current bounty-hunter) has a warrant, say "[The current bounty-hunter] watches you suspiciously."

We can do the same thing in defining rules:

> Instead of attacking a dangerous man (called the victim) when the player is unarmed:
> say "You rush at [the victim], who knocks you down with a well-aimed swing."

When we use "(called ...)", we create a new value or thing that varies - this is an example of a value which lasts only for temporary usage, but it can be used in the rest of the rule currently being defined.

Previous | Contents | Next