| Chapter 4: Kinds |

| 4.11. Values that vary

Sometimes a value important to the simulated world will not naturally belong to any thing or room, and should not be kept in a property. For example:

> The prevailing wind is a direction that varies. The prevailing wind is southwest.

Or "which varies" would also be allowed, as would the more traditional computing term "variable":

> The target is a number variable. The target is 23.

In fact, we have seen a value that varies already: "location", which holds the room in which the game is presently taking place.

It's important to tell Inform what kind of value goes into the variable, as this will ensure that the wrong kind of value is never accidentally put into it. But just as for properties, we do not need to say explicitly what the initial value is: and if we do not, Inform will use the default value for its kind. (See the table in the Kinds index.)

We can have variables of any of the kinds of value, including new ones, but should watch out for a potential error. If we write:

> The receptacle is a container that varies.

in a design which has no containers at all, Inform will object, because it will be unable to put any initial value into the receptacle variable. A similar complaint will be made if we write:

> Colour is a kind of value. The fashionable shade is a colour that varies.

without ever having defined any colours. Something else we are not permitted is:

> The receptacle is an open container that varies.

because the openness of a given container may change during play, so that the value in the variable might suddenly become invalid even though the variable itself had not changed.

48
| Example Real Adventurers Need No Help Allowing the player to turn off all access to hints for the duration of a game, in order to avoid the temptation to rely on them overmuch.

Previous | Contents | Next