Inform 7 Home Page / Documentation


Chapter 8: Change

§8.1. Change of values that vary; §8.2. Changing the command prompt; §8.3. Changing the status line; §8.4. Change of either/or properties; §8.5. Change of properties with values; §8.6. Whose property?; §8.7. Moving things; §8.8. Moving backdrops; §8.9. Moving the player; §8.10. Removing things from play; §8.11. Now...; §8.12. Increasing and decreasing; §8.13. Checking on whereabouts; §8.14. More flexible descriptions of whereabouts; §8.15. Calling names; §8.16. Counting the number of things; §8.17. Looking at containment by hand; §8.18. Randomness; §8.19. Random choices of things

arrow-up-left.png Contents of Writing with Inform
arrow-left.png Chapter 7: Basic Actions
arrow-right.png Chapter 9: Time
arrow-down-right.png 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:

paste.png "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.


arrow-up.png Start of Chapter 8: Change
arrow-left.png Back to Chapter 7: Basic Actions: §7.18. Postscript on actions
arrow-right.png Onward to §8.2. Changing the command prompt