§2.3. Using the Player's Input

We may sometimes want to capture specific words the player has used and then feature that text elsewhere in the story.

Terracottissima Maxima demonstrates using text to describe objects; Mr. Burns' Repast lets the player refer to a fish by any of a number of names, and changes the way the fish is described as a result.

More specialized effects are also possible: Xot shows how to collect the player's erroneous input and store the command line to be printed back later. Igpay Atinlay shows how to parrot the player's command back in pig Latin form.

* See Animals for a dog which the player can re-name

* See Traits Determined By the Player for a way to let the player name the player character


arrow-up.pngStart of Chapter 2: Adaptive Prose
arrow-left.pngBack to §2.2. Varying What Is Read
arrow-right.pngOnward to Chapter 3: Place: §3.1. Room Descriptions

*ExampleIgpay Atinlay
A pig Latin filter for the player's commands.

**ExampleMr. Burns' Repast
Letting the player guess types for an unidentifiable fish.

***ExampleTerracottissima Maxima
Flowerpots with textual names that might change during play.

In Hitchhiker's Guide to the Galaxy, any erroneous command the player types can return to haunt him later in the game. We could do the same, if we liked, by storing the player's command whenever we print a parser error.

paste.png "Xot"

Humiliation Chamber is a room. "A grim, grey-walled room. Cameras watch you from every angle; convex mirrors reflect your actions; and up near the ceiling, where you can't disable it, is a loudspeaker."

The last error is a text that varies. The last error is "xot".

Before printing a parser error:
    now the last error is the player's command.

Every turn when a random chance of 1 in 2 succeeds:
    say "Over the loudspeaker comes some distorted nonsense. If you listen carefully, it sounds as though some fool is saying '[last error], [last error], [last error]!'"

Test me with "wiggle / z / z / z / z / z / z".

***ExampleXot
Storing an invalid command to be repeated as text later in the game.

In Hitchhiker's Guide to the Galaxy, any erroneous command the player types can return to haunt him later in the game. We could do the same, if we liked, by storing the player's command whenever we print a parser error.

paste.png "Xot"

Humiliation Chamber is a room. "A grim, grey-walled room. Cameras watch you from every angle; convex mirrors reflect your actions; and up near the ceiling, where you can't disable it, is a loudspeaker."

The last error is a text that varies. The last error is "xot".

Before printing a parser error:
    now the last error is the player's command.

Every turn when a random chance of 1 in 2 succeeds:
    say "Over the loudspeaker comes some distorted nonsense. If you listen carefully, it sounds as though some fool is saying '[last error], [last error], [last error]!'"

Test me with "wiggle / z / z / z / z / z / z".