Chapter 4: Kinds
4.9. Using new kinds of value in properties

Having created a new kind of value called "brightness", we are free to use it in the ordinary way like this:

The lantern has a brightness called the flame strength. The flame strength of the lantern is blazing.

The "flame strength" property is now only allowed to have one of four values we allowed: guttering light, weak light, radiant light or blazing light. Inform will not allow anything else to be put into it, or allow it to be compared to (say) the number 3.

However, it seems artificial to call the brightness of the lantern "flame strength", when we could instead simply call it "brightness", so we are also allowed this:

The lantern has a brightness. The lantern is blazing.

New kinds of value are very convenient when substituting variations in text:

A dead end is a kind of room with printed name "Dead End" and description "This is a dead end, where crags in the uneven rock are caught by the [brightness of the lantern] flame you hold aloft. Despite [river sound] there is no sign of the stream." A dead end is usually dark.

The "brightness of the lantern" in square brackets is printed not as literal text, but as whatever the brightness currently is. (This is called a text substitution, and will be the subject of the next chapter.) If the brightness had been a number from 1 to 4, this would have resulted in something like "... by the 3 flame...", but since it is a new kind of value, the result is "... by the radiant flame..."

* See Text with substitutions for more on varying what is printed


50
* Example  The Undertomb
A small map of dead ends, in which the sound of an underground river has different strengths in different caves.

RB

This example creates a kind of room, "dead end", and gives each a textual description called its "river sound". Note the use of a text substitution to fill in the appropriate river sound text in each dead end.

"The Undertomb"

A dead end is a kind of room with printed name "Dead End" and description "This is a dead end. You'll have to go back the way you came, consoled only by [river sound]." A dead end is usually dark.

The Undertomb is a dark room. East is a dead end. South is a dead end with printed name "Collapsed Dead End". Northwest is a dead end called the Tortuous Alcove. In the Undertomb is the lantern. It is lit.

A dead end has some text called river sound. The river sound of a dead end is usually "a faint whispering of running water". The Tortuous Alcove has river sound "a gurgle of running water".

Test me with "get lantern / e / w / s / n / nw / se".

51
*** Example  The Crane's Leg 1
A description text that automatically highlights the ways in which the object differs from a standard member of its kind.

RB
52
*** Example  Signs and Portents
Signpost that points to various destinations, depending on how the player has turned it.

RB


PreviousContentsNext