Chapter 8: Change

 Contents of Writing with Inform Chapter 7: Basic Actions Chapter 9: Time Indexes of the examples

§8.1. Change of values that vary

So far, what we have done in response to the player's commands amounts to little more than a few ripostes. The simulated world does change during play, as the player moves from room to room or picks up things, but all of this is happening automatically, not at our direct instruction. How then can we make the world change?

Recall that the world consists of rooms, in which are things, and that all of these have properties appropriate to their kinds. Some properties are either/or ("open" or "closed" but not both and not neither), while others have values (the "matching key" of a lockable door, for instance). Finally, we may also have created some free-standing values or "variables".

We take the last example first, as it is the simplest. Suppose we have:

"Winds of Change"

The prevailing wind is a direction that varies. The prevailing wind is northwest.

The Blasted Heath is a room. "Merely an arena for the play of witches and kings, my dear, where the [prevailing wind] wind blows."

Instead of waiting when the prevailing wind is northwest:
say "A fresh gust of wind bowls you over.";
now the prevailing wind is east.

The new phrase here is "now". This automatically checks that the new value is one which makes sense in the given context, so for instance it would not allow either of these:

now the prevailing wind is 25;
now the prevailing wind is the Heath;

the former being a number, and the latter a room, so that neither is a direction. Similarly, "now" will not allow constant values to be changed. So

Colour is a kind of value. The colours are blue, red and mauve.

After pulling the psychedelic lever:
now blue is mauve.

...will result in a problem message; it's like writing "now 1 is 2". The difference between "the prevailing wind" and "blue" is that the wind was declared to be a "direction that varies", whereas blue wasn't.

 Start of Chapter 8: Change Back to Chapter 7: Basic Actions: §7.18. Postscript on actions Onward to §8.2. Changing the command prompt