Inform 7 Home Page / Documentation
§17.11. Understanding values
"Understand" can be used to supply new ways to talk about both things and other values. For instance, if we create:
A brass lantern is in the Building.
then it can be called "brass", or "lantern", but not "lamp": Inform does not really know what these words mean, and has no grasp of synonyms. We can arrange for "lamp" to work as well like so:
Understand "lamp" as the lantern.
Understand "old lamp" as the lantern.
With care, we can do the same trick for entire kinds of thing at once. It is not ordinarily the case that a thing can be called by the name of its kind: if we put a woman called April into a room, then she can usually be called "April", but not "woman". (The exception is when we do not specify any name for her - in that case, Inform will give up and call her just "woman".) So there is not usually any form of words which can refer to anything of a given kind. If we should want this, we have to say so explicitly:
Understand "machine" as a device.
Device is a kind, so now the word "machine" can be used to refer to any device: if there are two in the same place, the result might play out like so:
>switch machine on
Which do you mean, the bale twiner or the grain thresher?
>twiner
You watch absorbed as a perfect cube of hay is trussed up like a parcel.
Similarly, we might conceivably want to allow new ways to recognise values - in this case, a number:
Understand "eleventy-one" as 111.
When making complicated names, we need to watch out for the possibility of writing a definition which will cause Inform to go around in circles (something which will show up as a "Too many activities at once" run-time problem). For instance,
Understand "[thing] substitute" as the placebo.
will fail because Inform, working left to right, needs to look for every possible object name before it can progress: one possibility is the placebo itself: to check that, it needs to look for every possible object name: and so on, never finishing. A definition like this one very likely matches too much in any case (would we really want to accept PLACEBO SUBSTITUTE or CIGARETTE SUBSTITUTE SUBSTITUTE SUBSTITUTE here, as the definition implies?).
|
ExamplePalette
An artist's workshop in which the canvas can be painted in any colour, and where painterly names for pigments ("cerulean") are accepted alongside everyday ones ("blue").
|
|
There are hundreds of traditional pigments, from lampblack to burnt sienna, so we will confine ourselves to just two:
"Palette"
The Atelier is a room. "The floridly untidy loft space used by a moderately unsuccessful artist (you, that is)." The canvas, palette and paint brush are here. Understand "painting" as the canvas.
Colour is a kind of value. The colours are white, red, blue and green.
The canvas has a colour. The canvas is white. The printed name of the canvas is "largely [colour] canvas".
Painting is an action applying to one thing and one colour. Check painting: if the noun is not the canvas, say "Centuries of tradition suggest that canvas is the natural home of paint." instead. Carry out painting: now the colour of the canvas is the colour understood. Report painting: say "You splash away at the now [canvas]."
Understand "paint [something] [a colour]" as painting.
Understand "calico" as white. Understand "cerulean" or "cerulean blue" as blue.
Test me with "examine canvas / paint canvas red / examine canvas / paint canvas cerulean / examine canvas".
The "reading a command" activity is rather advanced; for the moment, what we need to understand is that we're intervening in commands at the start of play and insisting that the player's first instruction to the game consist of a choice of gender. After that point, the gender will be set and play will proceed as normal.
In order to do the parsing, we define gender as a kind of value, and give several alternate names to each gender.
"Baritone, Bass"
Getting Started is a room.
Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.
A person has a gender. The gender of the player is unknown.
When play begins:
now the command prompt is "Please choose a gender for your character. >".
After reading a command when the gender of the player is unknown:
if the player's command includes "[gender]":
now the gender of the player is the gender understood;
if the gender of the player is unknown:
say "This story requires a selection of male or female. [run paragraph on]";
reject the player's command;
if the gender of the player is masculine, now the player is male;
if the gender of the player is feminine, now the player is female;
say "[line break]Thank you. We now begin...";
now the command prompt is ">";
move the player to Sandy Beach;
reject the player's command;
otherwise:
say "Sorry, we're not ready to go on yet. [run paragraph on]";
reject the player's command.
Sandy Beach is a room.
Instead of examining the player when the player is female:
say "Congratulations, you are a girl!"
Instead of examining the player when the player is male:
say "Congratulations, you are a boy!"
If we had a whole series of things to ask the player about, we might define a whole series of kinds of value
The vocal ranges are soprano, mezzosoprano, contralto...
and use a "construction stage" variable to keep track of the current stage of character-construction, as in
After reading a command when the current construction stage is choosing a vocal range:
...