1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00
inform7/resources/Documentation/Examples/Ahem.txt
2019-03-16 13:12:11 +00:00

36 lines
1.5 KiB
Plaintext

* Pattern matching
(Phrase to repeat a rule--Phrase to let us say things some number of times; Ahem)
Writing a phrase, with several variant forms, whose function is to follow a rule several times.
As we see in the example here, it is possible to use slashed variations in more than one place in a phrase, and to offer a number of separate forms. The main rule of thumb to remember is that value inputs for the phrase should always be separated by some text; so
To do/follow (chosen rule - a rule) exactly/precisely/just/-- (N - a number) time/times:
....
would cause a problem when we tried to call it with
follow the throat-clearing rule 2 times.
In general, we probably don't need to make our phrase definitions quite so flexible as this, but it's a good idea to account for "a" vs. "the", and for the possibility of using singular and plural forms, especially when writing extensions or other source to be shared.
{*} "Ahem"
To do/follow (chosen rule - a rule) exactly/precisely/just (N - a number) time/times:
repeat with index running from 1 to N:
follow chosen rule.
This is the throat-clearing rule:
say "'Ahem,' says [a random visible person who is not the player]."
After waiting:
do the throat-clearing rule just one time.
Instead of listening:
follow the throat-clearing rule precisely three times.
Instead of smelling:
follow the throat-clearing rule exactly 2 times.
Chateau Marmont is a room. Tom, Jack, Zsa-Zsa, and Wilma-Faye are people in the Chateau. Zsa-Zsa and Wilma-Faye are women.
Test me with "wait / smell / listen".