2.3. Using the Player's Input

| Chapter 2: Adaptive Prose |

| 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 game.

Terracottissima Maxima demonstrates using indexed 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

307
| Example Terracottissima Maxima Flowerpots with textual names that might change during play. |
WI

411
| Example Mr. Burns' Repast Letting the player guess types for an unidentifiable fish. |
WI

Suppose we have an unhappily mutated fish that the player can refer to by any of a number of species names, or any word followed by -fish. We want to reject these commands, but preserve a memory of what the player last tried to call the thing: "Mr. Burns' Repast" Wharf is a room. There is an unknown fish in the Wharf. The unknown fish has some indexed text called supposed name. The description of the unknown fish is "The victim of heavy mutagens, this thing is not really recognizable as any species you know.". Fish variety is a kind of value. The fish varieties are salmon, albacore, mackerel. Rule for printing the name of the unknown fish: if the supposed name of the unknown fish is "", say the printed name of the unknown fish; otherwise say the supposed name of the unknown fish. After reading a command: let N be indexed text; if the unknown fish is visible and player's command matches the regular expression "\b\w+fish": let N be the player's command; replace the regular expression ".*(?=\b\w+fish)" in N with ""; now N is "[N](?)"; now the supposed name of the unknown fish is N; respond with doubt; reject the player's command; otherwise if the unknown fish is visible and the player's command includes "[fish variety]": now supposed name of the fish is "[fish variety understood](?)"; respond with doubt; reject the player's command. To respond with doubt: say "You're not [italic type]sure[roman type] you're seeing any such thing." Test me with "get swordfish / look / touch monkfish / look / listen to tunafish / x fish / x salmon / look".

367
| Example Xot Storing an invalid command to be repeated as text later in the game. |
WI

409
| Example Igpay Atinlay A pig Latin filter for the player's commands. |
WI

Previous | Contents | Next