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".
"Undertomb 2"
Section 1 - Procedure
Brightness is a kind of value. The brightnesses are guttering, weak, radiant and blazing.
A brightness can be adequate or inadequate. A brightness is usually adequate. Guttering is inadequate.
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.
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.
A dead end has some text called river sound. The river sound of a dead end is usually "a faint whispering of running water".
Section 2 - Scenario
The Undertomb is a dark room. "From this dim cross-groined room, exits depart east, south, and northwest."
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. The Tortuous Alcove has river sound "a gurgle of running water".
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."
In the Undertomb is a lantern. It is lit. The lantern has a brightness. The lantern is blazing. The description of the lantern is "The lantern shines with a flame at [temperature of the brightness of the lantern]."
After waiting in the Tortuous Alcove when the brightness of the lantern is not guttering:
now the lantern is the brightness before the brightness of the lantern;
say "You wait so long that your lantern dims a bit."
Test me with "east / west / get lantern / east / west / south / north / northwest / read book / x lantern / z / x lantern / read book / look / z / x lantern / read book / look / z / x lantern / read book / look".
When you see a long object, you don't have to think that it is too long if being long is the property given by the nature. It is proved by the fact that a duckling, having short legs, will cry if you try to draw them out by force, and that a crane, having long legs, will protest you with tears if you try to cut them with a knife. -- Zhuangzi
Suppose we have an extremely detailed world model in which every object is characterized by many features -- in this example, material and height, though one could add more. Suppose further that we would like to generate descriptions of these things automatically for the most part, drawing the player's attention only to those aspects of the object that are particularly interesting.
"The Crane's Leg"
Material is a kind of value. The materials are wood, glass, stone, cloth, paper, clay, and metal. A thing has a material.
A height is a kind of value. 3 feet 11 inches specifies a height. A thing has a height. Definition: a thing is tall if its height is 6 feet 0 inches or more. Definition: a thing is short if its height is 2 feet 0 inches or less.
So far, we have generally dealt with cases where the property of a thing can be a number (such as 3), a value (such as brightness), or a unit (like height, here). It is also possible for a thing to have a property which names another thing, as in "The mother of the baby trout is the large trout" -- where "mother" is a property, and its value, in the case of the baby trout, is large trout. We would define such a property with a line such as "A fish has a thing called the mother."
In practice, though, this is a bit confusing as syntax; moreover, Inform has a much more powerful construct for talking about the ways in which one object relates to another object. A full discussion of this will have to wait for the chapter on Relations. For now, it is enough to say that we can do this:
Imitation relates various things to one thing (called the ideal). The verb to imitate means the imitation relation.
This will allow us to declare that some objects imitate other objects, like so:
A chair is a kind of supporter. A chair is always enterable. A chair is usually wood. The height of a chair is usually 4 feet 0 inches. The ordinary chair is a chair. Every chair imitates the ordinary chair.
A table is a kind of supporter. A table is usually wood. The height of a table is usually 3 feet 8 inches. The ordinary table is a table. Every table imitates the ordinary table.
A rock is a kind of thing. A rock is usually stone. The ordinary rock is a rock. Every rock imitates the ordinary rock. The height of a rock is usually 0 feet 3 inches.
A jug is a kind of container. A jug is usually clay. The ordinary jug is a jug. Every jug imitates the ordinary jug. The height of a jug is usually 0 feet 8 inches.
Now each of these types has one ideal representative which has the fundamental attributes of its kind: the ordinary chair is the most chairlike chair imaginable, the ordinary table is the epitome of tableness, and so on. We are also allowed to refer to "the ideal of the chair", thanks to the way we defined imitation. (Again, the relations chapter offers a much more detailed explanation of how relations may be defined.)
The description of a thing is usually "[comparison with ideal][run paragraph on]".
To say comparison with ideal:
let the sample be the ideal of the noun;
if the sample is not a thing:
say "Perfectly conforming to your expectations of its type.";
rule succeeds;
if the material of the noun is not the material of the sample:
if the height of the noun is not the height of the sample:
if the noun is shorter than the sample, say "Unusually short at [height of the noun], and made of [material of the noun].";
otherwise say "Unusually tall at [height of the noun], and made of [material of the noun].";
otherwise:
say "Distinct mostly in being made of [material of the noun].";
otherwise:
if the height of the noun is not the height of the sample:
if the noun is shorter than the sample, say "Unusually short at [height of the noun].";
otherwise say "Unusually tall at [height of the noun].";
otherwise:
say "In every respect [a sample]."
The Pleasure Garden is a room. "At the riverbank, a pleasing garden, having many curving paths and one straight."
The low table is a table in the Pleasure Garden. The height of the low table is 2 feet 3 inches. On the low table is a metal rock called a gold nugget.
Test me with "x table / x nugget".
So far the effect is not very deep, but we could take the auto-description a great deal further: providing a larger and more interesting set of variations; or writing a complicated set of rules such that the player only notices height variations when carrying a ruler; or switching between several player-characters, each of whom notices a different subset of characteristics. But these refinements would require more input from later chapters.
"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 make use of some action rules:
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".