Player's command / Run-time error P39 with multiple commands

Hi there,

I’m trying to track down a P39 runtime error in my WIP, and think I have stumbled upon on a bug (or I’m doing something illegal). Consider the following:

[code]“Player’s Command Test”

room1 is a room.

Jim is here. Jim is a man.
A pear is here. An orange is here.

Persuasion rule for asking Jim to try doing something: persuasion succeeds;

To decide whether (snp - a snippet) is/are invalid: (- ( ({snp} < 101) || (({snp} % 100) < 1) ) -).

Every turn:
if the player’s command is invalid:
say “player’s command invalid”;
otherwise:
say “player’s command valid[line break]”;
say “player’s command = [player’s command]”;

test me with “jim, get pear. get orange”.[/code]

This generates “*** Run-time problem P39: Attempt to say a snippet value which is currently invalid: words 1 to 7.” Why? I’m completely confused by this as “player’s command is invalid” returns false, so printing the player’s command should be okay…

Thanks,

Matt

The parser does reconstruction on the command line when it encounters a “.”. The first part of the command is wiped out and then the whole is reparsed. So snippets are invalid after that.

Actually it looks like the player’s command snippet is readjusted during this process. You see that after the second command, the snippet displays as “jim, get orange”. But there must be a point in between where it’s not valid – it still claims to cover seven words, but there aren’t seven words in the buffer any more.

It’s not all that safe to rely on snippets after the reading-a-command stage. If you want to save the player’s command, do this:

Command-text is initially "".

After reading a command:
	now command-text is the player's command.

This converts the snippet into a (fully substituted) text, which will not change.