mirror of
https://github.com/ganelson/inform.git
synced 2024-07-08 01:54:21 +03:00
43 lines
1.9 KiB
Plaintext
43 lines
1.9 KiB
Plaintext
Example: * Wesponses
|
||
Location: Issuing the response text of something
|
||
RecipeLocation: Varying What Is Written
|
||
Index: Altering response text programmatically
|
||
Description: Parser messages that are delivered with a speech impediment.
|
||
For: Z-Machine
|
||
|
||
If we want to change individual responses to player action, then the best thing to do is to use the response facility to modify those selections, as shown in the chapter on [Responses].
|
||
|
||
However, suppose what we want is to give the parser a speech impediment that slightly alters all of the responses it issues. For this purpose, we might need to do a bit of text replacement...
|
||
|
||
{*}"Wesponses"
|
||
|
||
The Office is a room. Barry Kripke is a man in the Office. Kripke carries a badge.
|
||
|
||
The response inhibition is initially false.
|
||
|
||
Rule for issuing the response text of a response (called R) when response inhibition is false:
|
||
now response inhibition is true;
|
||
let output be "[text of R]";
|
||
now response inhibition is false;
|
||
replace the text "r" in output with "w";
|
||
replace the text "R" in output with "W";
|
||
say "[output]".
|
||
|
||
Test me with "i / x barry / get badge / listen / waffle / jump"
|
||
|
||
Notice that this doesn't affect the printed names of objects in the room description or other kinds of output text – only those that are issued by the response mechanism.
|
||
|
||
It would also not work to try to give our parser a nervous personality by simply adding ``Um, `` to the beginning of each response, because responses are not guaranteed to be full standalone sentences. For example, we could imagine writing
|
||
|
||
Rule for issuing the response text of a response (called R) when response inhibition is false:
|
||
now response inhibition is true;
|
||
let output be "Um, [text of R]";
|
||
now response inhibition is false;
|
||
say "[output]".
|
||
|
||
but here is what the room description would say as a result:
|
||
|
||
Office
|
||
Um, You Um, can see Barry KripkeUm, here
|
||
|