Graphical Window Sprites
version 1 by Erik Temple
Part 6 - Silent Replacement Commands
[The following code revises (and replaces) the print text to the input prompt rule from Glulx Entry Points so that it checks for the $- prefix that indicates a silent command; i.e., one that we don't want to appear in the transcript. On locating it, the new rule deletes the prefix while rerouting around the code that writes the command to the input prompt.]
Silent-replacement is a truth state that varies. Silent-replacement is false.
The print text to the input prompt rule is not listed in any rulebook.
A command-showing rule (this is the select text for printing to the input prompt rule):
if glulx replacement command matches the regular expression "^\$-":
replace the text "\$-" in glulx replacement command with "";
now silent-replacement is true;
say glulx replacement command;
say roman type.
[The following paragraphs are a hack that works around the built-in behavior of the system to ensure that the command line displays correctly when silent commands are issued. Basically, it suppresses the command prompt from printing again after a silent command has been issued. To use a custom command prompt throughout a game, include a "when play begins" rule that changes the command prompt; no other customizations should be necessary. If you wish to change the command prompt in mid-game, however, the safest thing is to change both the buffered command-prompt and the command prompt variables to the new prompt. ]
Buffered command-prompt is some text that varies.
The last when play begins rule:
Change buffered command-prompt to the command prompt.
After reading a command (this is the silent-replacement command-prompt rule):
if the command prompt is "":
change the command prompt to the buffered command-prompt;
if silent-replacement is true:
change the buffered command-prompt to the command prompt;
change the command prompt to "";
now silent-replacement is false.