§4.12. 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. In fact, we have seen a value that varies already: "location", which holds the room in which the story is presently taking place. Here's how we might make a new one:

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 prevailing wind is a direction variable. The prevailing wind is southwest.

A briefer way to do this is to use the word "initially", which alerts Inform to the possibility that the value will change in future:

The prevailing wind is initially southwest.

This creates the variable and gives it an initial value all in one sentence.

It's not compulsory to give an initial value. If we do not, Inform will use the default value for its kind. (See the table in the Kinds index.) For example, writing just

The grand tally is a number that varies.

will start it at the value 0, because that's the default value for numbers.

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 world 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.

As a final note on kinds, when Inform reads something like this:

Peter is a man. The accursed one is initially Peter.

it has to make a decision about the kind of "accursed one". Peter is a "man", so that seems like the right answer, but Inform wants to play safe in case the variable later needs to change to a woman called Jane, say, or even a black hat. So Inform in fact creates "accursed one" as an object that varies, not a man that varies, to give us the maximum freedom to use it. If we don't want that then we can override it:

Peter is a man. The accursed one is initially Peter.
The accursed one is a man that varies.

thus telling Inform exactly what is intended.

 Start of Chapter 4: Kinds Back to §4.11. Default values of kinds Onward to §4.13. Values that never vary

 ExampleReal 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.