4.9. Using new kinds of value in properties

| Chapter 4: Kinds |

| 4.9. Using new kinds of value in properties

It turns out to be very useful to create a new kind of value, and then create a property to hold it. So useful, in fact, that Inform provides two shortened forms for doing so. Here is the first, and the second (making "conditions") is in the section following.

Suppose we go back to our example of the candle lantern whose brightness we have to measure. It's clear that what we want to do is to define:

> Brightness is a kind of value. The brightnesses are guttering, weak, radiant and blazing.

And now we can use the technique of the previous section:

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

This works very nicely. 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. So we have succeeded in recording our measurement.

But it seems artificial to call the brightness of the lantern "flame strength", when we could instead simply call it "brightness". Much simpler to write:

> The lantern has a brightness. The lantern is blazing.

Now "brightness" is the name of both the property and the kind of value. What's particularly nice is that we can now use the names of the possible brightnesses - "weak", "blazing" and so on - as adjectives. Inform knows that "The lantern is blazing" must be talking about the brightness property, because "blazing" is a brightness.

Now we can improve our dead ends:

> 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]" is printed not as literal text, but as whatever the brightness currently is. (The square brackets mark it as what is called a text substitution, which will be the subject of the next chapter.) So we get something like this:

> This is a dead end, where crags in the uneven rock are caught by the blazing flame you hold aloft. Despite a faint whispering of running water there is no sign of the stream.

So now we have a lantern, which has a brightness as a property. But we can build on this further if we like. A brightness such as "guttering" is a value, so it can have properties in its own right. That can be quite useful, in fact:

> A brightness can be adequate or inadequate. A brightness is usually adequate. Guttering is inadequate.

This is convenient because it divides up the brightnesses:

> The player carries a book. The description of the book is "[if the brightness of the lantern is adequate]Many secrets are now yours.[otherwise]No, the print's too tiny by this awful light."

And while we're at it, let's give each brightness its own corresponding temperature:

> Temperature is a kind of value. 100C specifies a temperature.

> A brightness has a temperature. The temperature of a brightness is usually 700C. The temperature of blazing is 1400C. The temperature of radiant is 1100C.

> The description of the lantern is "The lantern shines with a flame at [temperature of the brightness of the lantern]."

(Candle flames are hotter than most people think.)

See Text with substitutions for more on varying what is printed

48
| Example The Undertomb 1 A small map of dead ends, in which the sound of an underground river has different strengths in different caves. |
RB

49
| Example The Undertomb 2 Flickering lantern-light effects added to the Undertomb. |
RB

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

"Signs and Portents" Seven Dials is a room. The description of Seven Dials is "There is a signpost, on which seven hands swivel and swing, freely as weathercocks. They make your present road now London, now Abingdon; now Weston-super-Mare, or now Hell." Seven Dials contains a signpost. The signpost is scenery. Understand "sign" and "post" as the signpost. Destination is a kind of value. The destinations are London, Abingdon, Luton, Weston-super-Mare, Runnymede, Hell, and Low Noon. The signpost has a destination. In order to interact with the signpost, we will need to borrow some action rules from chapter 6: Instead of examining the signpost: say "[The signpost] currently puts you on the road to [italic type][the destination of the signpost][roman type], but it swiftly alters again."; now the destination of the signpost is the destination after the destination of the signpost. Instead of turning the signpost: now the destination of the signpost is the destination after the destination of the signpost; say "With a hand's touch you turn the signpost to mark your way for [italic type][the destination of the signpost][roman type]." Instead of going north in Seven Dials when the destination of the signpost is Hell: say "It is a path that goes gently ever down and down with no stumbling block or any distraction at either side; there are no bandits and no tolls."; end the story. Instead of going north in Seven Dials when the destination of the signpost is Low Noon: say "A long road whose scenery does not change, nor anything on the horizon move but the sun. When at last you come to Noon, she hangs above your head like a hat."; end the story finally. Test me with "x signpost / n / turn signpost / n / turn signpost / n / turn signpost / n / turn signpost / n". Test more with "x signpost / n / turn signpost / n / turn signpost / n / turn signpost / n / turn signpost / turn signpost / n".

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

Previous | Contents | Next