Inform 7 Home Page / Documentation
§7.4. Try and try silently
Chapter 2 noted that surveys of Inform source text showed that the three most popular phrases used by authors are "say", "if" and "now". The fourth most popular is "try", which allows us to trigger off actions ourselves, rather than waiting for the player to type something which generates them. Thus:
try (action)
This phrase makes the action, which has to be named literally, take effect now. Example:
Instead of entering the trapdoor, try going up.
It's as if the player had typed GO UP as a command. Note that the action has to be specific:
try eating something;
is not allowed, since it doesn't say exactly what is to be eaten.
The word "try" is intended to make clear that there is no guarantee of success. For example:
Before locking the front door, try closing the front door.
could go wrong in any number of ways - perhaps the door is closed already, perhaps it is not openable, perhaps somebody has wedged it open. It would be safer to write:
Before locking the front door:
try closing the front door;
if the front door is open, stop the action.
There's no need to say anything if closing didn't work, because the closing action will have done that already. A neater approach still is to use:
silently try (action)
or: try silently (action)
This phrase makes the action, which has to be named literally, take effect now, under the "silent" convention which means that routine messages aren't printed. Example:
try silently taking the napkin;
Silence is maintained only if this new action, the taking of the napkin, is successful (so if the napkin is successfully taken, the text "Taken." will not appear): if the action should fail, a suitable objection will be voiced as usual.
So now we have:
Before locking the front door:
try silently closing the front door;
if the front door is open, stop the action.
And this is neater because it won't produce a pointless "You close the front door." message.
See Stored actions for how to store up actions as values and try those, too, so that isn't necessary to name the action as literally as in the examples above
|
ExampleFine Laid
Making writing that can be separately examined from the paper on which it appears, but which directs all other actions to the paper.
|
|
Sometimes it is useful to direct all -- or almost all -- actions from one object to another. For the sake of argument, say we have a sheet of paper with writing on it, and (because we're very meticulous) we want to let the player examine the writing and get a customized response, different from when he just examines the sheet of paper. But for all other purposes -- say, TAKE or TASTE -- we want the two objects to be treated as one.
Here, we approach the problem by changing the noun and/or the second noun of the current action, then issuing a new command to "try the current action". Because we've changed the noun and second noun, the "current action" at this point is different from the one generated originally by the player's command.
"Fine Laid"
High Street Stationer is a room.
The sheet of paper is a thing in High Street Stationer. The writing is part of the sheet of paper.
The description of the sheet of paper is "A beautiful sheet of heavy cream paper." The description of the writing is "Delicate and spidery."
Instead of tasting the sheet of paper, say "You might need more fiber in your diet, but this isn't the way.".
Before doing something other than examining when the current action involves the writing:
if the writing is the noun, now the noun is the sheet of paper;
if the writing is the second noun, now the second noun is the sheet of paper;
try the current action instead.
Test me with "examine sheet of paper / examine writing / get writing / taste writing".
|
ExampleHayseed
A refinement of our staircase kind which can be climbed.
|
|
Presumably all staircase-type connections between rooms should respond when the player says CLIMB STAIRS (or the equivalent). So
"Hayseed"
A staircase is a kind of door. A staircase is usually open. A staircase is seldom openable.
The ladder is a staircase. It is above the Barn and below the Hayloft.
Instead of climbing a staircase:
try entering the noun.
Test me with "climb ladder / g".
Attempts to climb other types of door will still be treated as useless.