Printing a parser error happens way after reading a command. The parser error will be printed after the command has been read and the parser has given up on it. It looks to me as though what your code ought to do is print the parser error and then change the next command to the corrected text. If it doesn’t do that, it’s probalby because you’ve written a rule for reading a command as opposed to one after reading a command; I have no idea what happens if you try to put new rules in there. (See section 17.31.)
Unless you’re going to do some very very serious messing with the parser, I don’t think you’re going to be able to replace text in the command only when the parser failed to parse it. If you want to replace text, you have to do it before the parsing happens, which means you’ll have to do it every time.
So you could try this:
[code]Understand “myy” as a thing when the item described is carried by the player.
Understand “your” as a thing when the item described is carried by a person and the item described is not carried by the player.
After reading a command:
if the player’s command includes " my " begin;
replace the matched text with “myy”;
say “The player’s command is [the player’s command].”;
end if.
Arena is a room. Amy is a woman in arena. Amy carries a bastard sword. The player carries a short sword.
Test me with “x my sword/x your sword/amy, x my sword/amy, x your sword”.
Persuasion rule: persuasion succeeds.[/code]
It might be better to use regular expressions so that you can capture “my” when it’s its own word but not set off by spaces. (The regexp for this is “\bmy\b” I think.) I was a bit too lazy to do that now. Note that Amy’s name does not get messed with (I would advise against doing an IF adaptation of the Moomin stories featuring Little My). The normal behavior of the word “my” may get messed with, where “my” refers to absolutely anything and not just things you’re carrying, but eh, that’s not so bad. The behavior of “your” is a bit funny as the second command reveals; you could make it more intuitive by changing the relevant Understand line to:
Understand "your" as a thing when the item described is carried by the person asked.
Oh, also note that if you’re going to do snippet matching the way I did in this example you say “the player’s command matches ‘my’” if you want the case where “my” is the entire command and “the player’s command includes ‘my’” if you want the case where “my” is a bit of the command. If you’re going to do a regular expression I guess that you want “replace the regular expression ‘\bmy\b’ in T with ‘my’” and that’s OK. But if you actually want to test a regular expression you want “if T matches the text ‘my’” for the case where “my” is part of T and “if T exactly matches the text ‘my’” for the case where “my” is the entirety of T. The two different uses of “matches” drive me crazy; I wrote “matches” instead of “includes” in my test code and I had just looked at the documentation for it.