| Chapter 14: Units |

| 14.6. Units

Some of the examples in the last few sections were slightly strained because they used numbers where an English speaker not quite do so. We tend not to say "Isabella has height 68": we would more normally say "Isabella is 5 foot 8." Perhaps the computer will need to store that measurement as the number 68 in some register or other, but we really don't want to know that.

Inform allows us to create new, basically numerical kinds of value, like so:

> A weight is a kind of value. 10kg specifies a weight.

By contrast, the kinds of value seen so far have been set up thus:

> A colour is a kind of value. The colours are red, green and blue.

We can choose to make a new kind of value of either variety, but we can't mix the two in the same kind: it will either be numerical at heart ("10kg") or verbal at heart ("blue").

The effect of "10kg specifies a weight" is to tell Inform that text matching this form is a constant value of kind "weight". So, for instance,

> The maximum load is a weight that varies. The maximum load is 8000kg.

> if the maximum load <= 8000kg, ...

Weights behave just like numbers in the ways we can compare them: but Inform respects the fact that a weight is not just any number, so it would not allow us to compare (say) "8000kg" and "5 foot 8". Weights can meaningfully be compared only with other weights.

We can also say weights:

> The Weighbridge is a room. "A sign declares that the maximum load is [maximum load]."

...which will produce the text "A sign declares that the maximum load is 8000kg."

196
| Example rBGH The player character's height is selected randomly at the start of play.

As with ordinary numbers, we can choose random units when this is useful: "rBGH" The Pharmaceutical Testing Facility is a room. "A [if the player is short]large [end if][if the player is tall]cramped [end if]white space with sterile counters and a[if the player is tall]n uncomfortable little[end if] stool. There is also a mirror, behind which someone must be watching you. But you can't see through to that." A counter, a one-way mirror, and a stool are scenery in the Facility. The stool is an enterable supporter. The counter supports a plate. Height is a kind of value. 5 feet 11 inches specifies a height. 5'11 specifies a height. A person has a height. Definition: a person is tall if its height is 6 feet 0 inches or more. Definition: a person is short if its height is 5 feet 4 inches or less. When play begins: change the height of the player to a random height between 5 feet 2 inches and 6 feet 4 inches; change the right hand status line to "[height of player]". Instead of examining the player: say "You, Test Subject, are [height of the player] tall." The growth pill is a kind of thing. A growth pill is always edible. The description is usually "It is leaf-green and has a reassuring logo of a curling vine on the side. Nothing to worry about, nothing at all." Two growth pills are on the plate. After eating the growth pill: change the height of the player to the height of the player + 0 feet 6 inches; say "Your spine does something frightening and painful, and you find yourself looking down on the room from a wholly new angle."; try looking. Test me with "examine me / eat pill / examine me / eat pill / examine me".

197
| Example Wonderland Hiking Mount Rainier, with attention to which locations are higher and which lower than the present location.

Previous | Contents | Next