Determining rule which threw a RTP

Is there a good way to track down which rule threw a run-time problem? I’m suddenly getting a P39 (saying an invalid snippet) every time I give multiple commands to another person but I can’t find what’s causing this.

EDIT: Further information on the actual problem in case it helps: this happens every time another actor is given multiple commands on one line (ALICE, EAST THEN NORTH). The invalid snippet always seems to be the player’s entire command. One likely candidate was a reference to the player’s command in a persuasion rule, but commenting out that line has no effect on the RTP, and other references to the player’s command are almost exclusively in “after reading a command” rules.

Stupid question, but let me get it out of the way - isn’t RULES ON being in any way helpful?

That does show me all the rules that execute, but there are still 305 of them to go through. (A number which I hope to decrease, but that’s a separate issue.) The RTP prints after all the rules are finished executing, before starting the next turn.

This is not normally the case – in the standard runtime environment, RTPs are printed immediately.

RTPs are temporarily suspended when printing to a memory buffer. Converting a snippet to an I7 text is one such case, so I guess I’m not surprised that you see the RTP delayed.

Here’s what I bet is happening: the parser handles multiple NPC commands by wiping out part of the buffer and re-parsing. This makes the player’s command snippet (all snippets, in fact) invalid.

Simple example:

The Kitchen is a room. "You are in a kitchen."

The rock is a thing in the Kitchen.

Steve is a person in the Kitchen.

Persuasion rule:
	say "Snippet is '[the player's command]'.";
	persuasion fails.

In general, snippets should be used as early as possible.

I’ve narrowed down the rules…but now I’m even more confused than before. Here’s a short fragment of the output with rules-tracing on.

[Rule "RTP scope rule" applies.]
[Rule "multiple commands to a distant actor rule" applies.]

*** Run-time problem P39: Attempt to say a snippet value which is currently invalid: words 1 to 13.

Start distant actor

And here are the bits of code that cause it.

To decide if parsing for/-- persuasion: (- (scope_reason == 1) -).

To show RTPs: (- RunTimeProblemShow(); -).

Last after deciding the scope of the player (this is the RTP scope rule): show RTPs; make no decision.

After deciding the scope of the player while parsing for persuasion (this is the multiple commands to a distant actor rule):
	show RTPs;
	say "Start distant actor[br]";
	[...]

So the run-time problem is apparently arising between rules. I have no idea what could cause this, except that SearchScope is somehow doing snippet manipulation somewhere in there…???

The RTP is occurring early, but the display is suspended until the RunTimeProblemShow() call.

Oh, yeah, sorry, I didn’t explain fully. The output shows that the RTP must be happening in between rules: the “RTP scope rule” calls RunTimeProblemShow(), but nothing happened at that point, so it must be after it. The next RunTimeProblemShow() call is the first line of the “multiple commands to a distant actor rule”, and that one does show the problem message (as evidenced by the text appearing after the problem message rather than before).

Finally fixed. The error was being thrown due to a typo in the condition of an Understand line, which was translated into a parse_name routine. That was a mess.