# Snippetage

## version 2 by Dave Robinson

Example: * Pedantic Bob - Some simple printing and matching of snippets, and an input-quoting error message

"Pedantic Bob"

Include Snippetage by Dave Robinson.

The Pit is a room. "The pit looks the same as ever, and quite inescapable. Apart, possibly, from [the red door] to the south."

A door called a red door is south of the pit and north of Freedom. The description is "You have heard that the red door leads to freedom, but you don't know if you believe it.".
The red door is lockable and locked.

After going south from the pit, end the game in victory.
Before entering the red door, try going south instead.

Rule for writing a paragraph about the red door: now the red door is mentioned; rule succeeds.

The brass key unlocks the red door.

Bob is a man in the Pit. "Bob stands nearby.". The description is "Bob responds to commands. He doesn't usually obey them, but he often responds to them.".

Telling Bob about something is attempting conversation.
Answering Bob that something is attempting conversation.

Before attempting conversation:
say "Bob is not much interested in conversation, but he might respond to commands." instead.

if the verb word matches "x" begin;
say "'X!' Bob cackles. 'X marks the spot!'";
otherwise;
let n be the verb position;
if n is the end of the player's command, say "'I can [verb word] as much as you want,' Bob says. 'It won't help.'";
otherwise say "'You want me to [verb word]?' Bob says. 'Are you sure you mean [command from verb position onwards]?'";
end if.

Instead of asking Bob to try examining the parrot when the verb word matches "describe":
say "'Looks like a cockatoo to me,' Bob observes.";
now the parrot is renamed.
Instead of asking Bob to try examining the parrot, say "Bob looks over at [the parrot] and grunts boredly.".

A parrot is an animal in the Pit. The parrot is neuter.
"[A parrot] sits nearby giving the occasional squawk."
The parrot can be renamed. The description is "[if renamed]A fine example of a cockatoo[otherwise]It looks like a parrot, but you're not sure[end if][if the parrot is holding the brass key]. It's holding a brass key[end if].".
The parrot is holding a brass key.
Before taking the brass key, if the parrot is holding the key, say "[The parrot] flutters away as you reach for the key." instead.
Before taking the parrot, say "[The parrot] dodges away from you." instead.

After reading a command: if the player's command is valid and a random chance of 1 in 3 succeeds begin;
let n be the end of the player's command;
say "'Awwwk [word at n] [word at n] [word at n]!' [the parrot] shrieks.";
end if.

Understand "bird" as the parrot.
Understand "cockatoo" as the parrot when the parrot is renamed. The printed name of the parrot is "[if renamed]cockatoo[otherwise]parrot[end if]".

Before asking a parrot to try doing something:
if the word at 1 matches "parrot", say "'Parrot?' [the parrot] squawks. 'Who's a parrot?'" instead;
if the word at 1 matches "it", say "'It?' [the parrot] squawks. 'Oh, I'm [italic type]it[roman type] now, am I?'" instead;
if the word at 1 matches "bird", say "'Bird?' [the parrot] repeats incredulously. 'Is that the best you can do?'" instead.

Before asking the parrot to try giving the brass key to someone, try asking the parrot to try dropping the brass key instead.

Persuasion rule for asking the parrot to try doing something other than dropping:
say "[The parrot] just squawks.";
persuasion fails.
Persuasion rule for asking the parrot to try dropping: if the parrot is holding the noun, persuasion succeeds; otherwise persuasion fails.

After the parrot trying dropping the key, say "[The parrot] drops the key to the ground.".

In addition to annoying word-repeating characters, we can have a word-repeating parser, which repeats back words it didn't understand, something like this:

Rule for printing a parser error when parser error is not a verb I recognise:
say "The verb '[verb word]' is not needed in this game.".

Test me with "Examine parrot / It, drop key / Parrot, drop key / Bird, drop key / Bob, wait / Bob, x me / Bob, examine me / Bob, examine parrot / Bob, describe the parrot / Cockatoo, drop key / Scrape the cockatoo / Take the key / Unlock the door / Open it / South".