Runtime Replacements by Daniel Stelzer begins here.
Table of Text Macros
input (text) replacement (text)
with 16 blank rows.
Table of Regex Macros
input (text) replacement (text)
with 16 blank rows.
The temporary working text is initially "". [The replacement machinery doesn't seem to work on local variables.]
After reading a command:
if word number 1 in the player's command is "undef", make no decision; [Don't make replacements here!]
now the temporary working text is the player's command;
repeat through the Table of Text Macros:
replace the word "[input entry]" in the temporary working text with "[replacement entry]";
repeat through the Table of Regex Macros:
replace the regular expression input entry in the temporary working text with the replacement entry;
change the text of the player's command to the temporary working text.
Defining a replacement of is an action out of world applying to a topic. Understand "def [text]" as defining a replacement of.
Carry out defining a replacement of a topic:
create a replacement with input (the substituted form of "[topic understood]") and regex mode false.
Defining a regex replacement of is an action out of world applying to a topic. Understand "regex [text]" as defining a regex replacement of.
Carry out defining a regex replacement of a topic:
create a replacement with input (the substituted form of "[topic understood]") and regex mode true.
Undefining is an action out of world applying to a topic. Understand "undef [text]" as undefining.
Carry out undefining a topic:
let the count be zero;
repeat through the Table of Text Macros:
if the input entry is the topic understood:
blank out the whole row;
increment the count;
repeat through the Table of Regex Macros:
if the input entry is the topic understood:
blank out the whole row;
increment the count;
say "[bracket][count] replacements for '[topic understood]' removed.[close bracket][paragraph break]".
Listing macros is an action out of world applying to nothing. Understand "macro" or "macros" as listing macros.
Carry out listing macros:
say "Text replacements:[line break]";
if the Table of Text Macros is empty:
say " None defined. (Use 'def =