mirror of
https://github.com/ganelson/inform.git
synced 2024-07-08 01:54:21 +03:00
57 lines
2.8 KiB
Plaintext
57 lines
2.8 KiB
Plaintext
Example: * Apples
|
|
Location: Asking which do you mean
|
|
RecipeLocation: Clarification and Correction
|
|
Index: Disambiguation question giving items more explicit names
|
|
Description: Prompting the player on how to disambiguate otherwise similar objects.
|
|
For: Z-Machine
|
|
|
|
Inform by default detects whether two objects can be disambiguated by any vocabulary available to the player. If so, it asks a question; if not, it picks one of the identical objects at random.
|
|
|
|
Generally this produces good behaviour. Occasionally, though, two objects have some distinguishing characteristic that doesn't appear in the object name. For instance, suppose we've created a class of apples that can be told apart depending on whether they've been bitten or not:
|
|
|
|
An apple is a kind of thing. Consumption is a kind of value. The consumptions are pristine and bitten. An apple has a consumption. The description of an apple is "It is [consumption]."
|
|
|
|
Understand the consumption property as describing an apple.
|
|
|
|
The player can meaningfully type ``EAT BITTEN APPLE`` or ``EAT PRISTINE APPLE`` but if they type ``EAT APPLE`` Inform will, annoyingly, ask
|
|
|
|
Which do you mean, an apple or the apple?
|
|
|
|
This gives the player no indication of why Inform is making a distinction. So here we add a special `printing the name rule` to get around that situation:
|
|
|
|
{*}"Apples"
|
|
|
|
Orchard is a room.
|
|
|
|
An apple is a kind of thing. Consumption is a kind of value. The consumptions are pristine and bitten. An apple has a consumption. The description of an apple is "It is [consumption]."
|
|
|
|
Understand the consumption property as describing an apple.
|
|
|
|
Before printing the name of an apple while asking which do you mean: say "[consumption] ". Before printing the plural name of an apple while asking which do you mean: say "[consumption] ".
|
|
|
|
The player carries three apples.
|
|
|
|
Instead of eating a pristine apple (called the fruit):
|
|
say "You take a satisfying bite.";
|
|
now the fruit is bitten.
|
|
|
|
Instead of eating a bitten apple (called the fruit):
|
|
say "You consume the apple entirely.";
|
|
now the fruit is nowhere.
|
|
|
|
Inform will also separate the bitten from the pristine apples in inventory listings and room descriptions, even though it's not clear why; we can improve on that behaviour thus:
|
|
|
|
{**}Before listing contents: group apples together.
|
|
|
|
Rule for grouping together an apple (called target):
|
|
let source be the holder of the target;
|
|
say "[number of apples held by the source in words] apple[s], some bitten".
|
|
|
|
Before printing the plural name of an apple (called target):
|
|
let source be the holder of the target;
|
|
if every apple held by the source is bitten, say "bitten ";
|
|
if every apple held by the source is pristine, say "pristine ".
|
|
|
|
Test me with "i / eat apple / i / eat apple / pristine / i / eat apple / pristine / i".
|
|
|