16.9. Understanding kinds of value

| Chapter 16: Understanding |

| 16.9. Understanding kinds of value

In many cases, if K is the name of a kind of value, then Inform automatically makes an Understand token called "[K]" which matches only values of K. An example is "[number]", which matches text like 203 or SEVEN. There is a chart of the kinds of value in the Kinds index for a project, showing which ones can be understood in this way.

In particular, any newly created kind of value can always be understood. We make good use of that in the example game "Studious":

> "Studious"

> The Studio is a room. "The unreal world of the photographic studio, full of fake furniture, cantilevered stands and silver-white shades like miniature parachutes." The lumpy black camera is in the Studio. "A lumpy black camera hangs from a tripod."

> The rake-thin model is a woman in the Studio. "A rake-thin model, exquisitely bored and boringly exquisite, angles herself indolently."

> Limb is a kind of value. The limbs are left leg, left arm, right leg and right arm.

> Detailing is an action applying to one limb and one visible thing, requiring light. Check detailing: if the camera is not carried then say "You can hardly photograph without a camera, now can you?" instead. Report detailing: say "Click! You take a detail photograph of the [limb understood] of [the second noun]."

> Understand "photograph [limb] of [a person]" as detailing.

> Test me with "get camera / photograph left leg of model".

Note the way we can refer to the limb mentioned by the player as the "limb understood". Similarly, we could talk about the "number understood" if the value parsed had been a number, and so on.

One of the built-in kinds of value is worth special note: time. A time can hold either a specific time of day, such as 10:23 PM, or a duration of something, such as 21 minutes. The "[a time]" token matches times of day, such as 10:15 AM or MIDNIGHT. But 10 MINUTES wouldn't be recognised by "[a time]" since it isn't a specific moment in the day. To get around this, an alternative version called "[a time period]" is available. So:

> Understand "wait for [a time period]" as ...

would match WAIT FOR AN HOUR or WAIT FOR TWO HOURS 12 MINUTES.

292
| Example Pages A book with pages that can be read by number (as in "read page 3 in...") and which accepts relative page references as well (such as "read the last page of...", "read the next page", and so on). |
RB

293
| Example Down in Oodville Offering the player a choice of numbered options at certain times, without otherwise interfering with his ability to give regular commands. |
RB

294
| Example Straw Into Gold Creating a Rumpelstiltskin character who is always referred to as "dwarf", "guy", "dude", or "man" -- depending on which the player last used -- until the first time the player refers to him as "Rumpelstiltskin". |
RB

"Straw Into Gold" The Cell is a room. Rumpelstiltskin is an improper-named man in the Cell. Rumpelstiltskin can be identified or unidentified. Rumpelstiltskin is unidentified. R-name is a kind of value. The R-names are dwarf, guy, dude, and man-thing. Rumpelstiltskin has an R-name. Understand "[R-name]" as Rumpelstiltskin. Our example is slightly complicated by the fact that "man" is a name already known to Inform, so we can't re-use it as a kind of value. This is possible to work around, though: Understand "man" as man-thing. Now we borrow from the Activities chapter to look at the exact wording of the player's command: After reading a command: if the player's command includes "[R-name]", now the R-name of Rumpelstiltskin is the R-name understood; if the player's command includes "Rumpelstiltskin": now Rumpelstiltskin is identified; now Rumpelstiltskin is proper-named. Rule for printing the name of Rumpelstiltskin when Rumpelstiltskin is unidentified: if the R-name of Rumpelstiltskin is man-thing: say "man"; otherwise: say "[R-name]". Test me with "x dwarf / x guy / x dude / look / x rumpelstiltskin / look / x man".

Previous | Contents | Next