I have a rule that prints out whatever player command caused a parser error. I have it because I’m making the player chose a name at the beginning of the story. The player can currently do this two ways. One is by typing a name (basically any non-command) directly in at the "> " command prompt and then confirming they want that as their name.
If a player enters “g” or “again” on the first turn, the story crashes saying [** Programming error: tried to print (char) 0, which is not a valid Glk character code for output **]. As far as I know, “again” basically replaces the player’s current command (“g” or “again”) with the last one. On the first turn, there is no last player’s command, or it’s some empty-ish default player command. So the current command is then set to something like “[some (char) 0]” that can’t be printed. I think I could fix this if I knew what that text is that Inform is failing to print. I could insert a check for that text and ignore it like I ignore all-whitespace commands. But I don’t know what that text is?
tl;dr: What is the text of the default player command at the beginning of a story; i.e., the command you get from typing “AGAIN” on the first turn?
Here’s the rule.
Rule for printing a parser error when player-name is unknown during Naming:
let temp-name be substituted form of "[the player's command]";
if temp-name exactly matches the regular expression "\s*": [player's command is all whitespace]
if collecting name:
say "You draw a blank. [line break]";
now the command prompt is "> ";
otherwise:
say "What? [line break]"; [recreates the default parser error for whitespace-only command]
otherwise:
say "[temp-name] - it sounds familiar. Is that your name?";
if the player consents:
now player-name is familiar;
now chosen-name is temp-name;
say "[naming-success]".
Here’s an abridged but still long runnable story that shows off the issue.
[spoiler][code]“What’s your name AGAIN?” by xxiggy
[To see me crash, type “g” or “again” on the first turn. Problem area is Section 3 at the end.]
The Featureless White Cell is a room. “Utterly featureless; impressively white.”
When play begins:
say “You awoke in a featureless white cell without so much as a visible door. A voice over an unseen intercom threatened to shoot you if you don’t tell it your name in the next 10 minutes. Well that was a few minutes ago, and you’d happily oblige - but first you need to [italic type]remember[roman type] your name.”;
let r be a random number between 4 and 8;
naming-fails in r turns from now.
At the time when naming-fails:
end the story saying “You are shot!”.
Section 1 - The Naming Scene
Include Epistemology by Eric Eve. Player-name is an unfamiliar subject.
Naming is a scene. Naming begins when play begins. Naming ends when player-name is familiar.
Chosen-name is some text that varies. Chosen-name is usually “UNKNOWN”.
Remembering is an action applying to one topic.
Understand “remember [text]” as remembering.
Understand “remember” as a mistake (“What do you want to remember?”).
Carry out remembering:
say “Nothing specific comes to mind.”
Instead of remembering “my/your/-- name”:
if player-name is unfamiliar:
now the command prompt is "What is your name? > ";
otherwise:
say “You are [chosen-name].”;
rule succeeds.
Name-remembering is an action applying to nothing. Understand “name” as name-remembering.
Instead of name-remembering:
if player-name is unfamiliar:
say “If you really can’t remember, you’d better make something up fast.”;
try remembering “name”.
Section 2 - Collecting Name
To decide whether collecting name:
if the command prompt is "What is your name? > ", yes;
no.
Understand “restart/restore/save/quit/hint/help/about/rules/actions” as “[meta-command]”.
After reading a command when collecting name (this is the naming rule):
if the player’s command matches “[meta-command]”:
now the command prompt is “>”;
make no decision;
otherwise:
now the chosen-name is the player’s command;
now player-name is familiar;
now the command prompt is “>”;
if player-name is unfamiliar and the player’s command does not match “[meta-command]”:
say “You really need to remember your name.[line break]”;
reject the player’s command;
otherwise if player-name is familiar:
say “[naming-success]”;
reject the player’s command.
To say naming-success:
say “You say your name - [chosen-name]. This must satisfy someone, because a door appears!”;
end the story finally saying “To be continued…”
[Edit: note: doesn’t actually end the story if a player’s just gone the route of typing something in and confirming it as their name. A problem for another time.]
Section 3 - The part that’s breaking things
Rule for printing a parser error when player-name is unknown during Naming:
let temp-name be substituted form of “[the player’s command]”;
if temp-name exactly matches the regular expression “\s*”: [player’s command is all whitespace]
if collecting name:
say “You draw a blank. [line break]”;
now the command prompt is "> ";
otherwise:
say “What? [line break]”; [recreates the default parser error for whitespace-only command]
otherwise:
say “[temp-name] - it sounds familiar. Is that your name?”;
if the player consents:
now player-name is familiar;
now chosen-name is temp-name;
say “[naming-success]”.
[/code][/spoiler]