[I7] Restarting the parser from an activity

Here’s my situation:

The player is providing an instruction to a character present. The game tries to disambiguate among options, and as a result, the next command entered fails.

By turning on actions, I can see that ANSWER intercepted the second action, as follows:

This is confusing the heck out of my playtesters, and I don’t blame them. :frowning:

What I want to do is something like this:

[code]Parser-restarted is a truth state that varies.

An every turn rule:
now parser-restarted is false.

Before answering someone (called the target person) that:
if parser-restarted is false:
restart the parser; ← Of course, this is the problem.
now parser restarted is true.[/code]

And then the behavior would be:

I found “after reading a command”, and tried an alternate solution - to store the player’s command each turn, then analyze it to figure out whether last turn’s snippet is included in the new command. Initial tests didn’t work out, though, because my code reported the last command matching no matter what (code below).

[code]The last command is a snippet that varies.

After reading a command:
if the player’s command is the last command:
dm “This was the same as your last command.”;
now the last command is the player’s command.[/code]

So I turn to the more-expert-than-me experts! How do I get around this problem?

Ouch. This of course (“of course”) occurs because the parser is pasting the commands together, producing “frog, drink frog, drink water”.

What confuses me here is that the parser is supposed to handle this case. There’s a comment:

    ! Look for a comma, and interpret this as a fresh conversation command
    ! if so:

I will have to run some tests and see why that isn’t tripping.

As for your final question, snippets are transitory – they are a pointer to the command buffer, so saving one between commands doesn’t work. This works:

The last command is an indexed text that varies.

After reading a command:
	if the player's command matches the text last command, case insensitively:
		say "This was the same as your last command.";
	now the last command is the player's command.

You’ll need to tune this further to get the result you want. For example, the first turn always triggers the message, because last command starts as “” and that’s always a subset of the player’s command. Also, any single-letter command (“i”, “n”) has a good chance of being a subset of the following command. But this demonstrates the mechanism.

One way to fine-tune that might be to set a flag when asking which do you mean, so that the after reading a command rule runs only when the player is typing a response to a which do you mean question.

I have encountered this in 6/11 as well. The following exchange fails as well:

paul, take
What do you want Paul to take?

east

The library produces nothing in reply to the “east” command.

Unfortunately, another bug in Inform means that the “after reading a command” rules don’t run after disambiguating an incomplete command like “EXAMINE” or “FROG, DRINK” (something which I ran up against in my own WIP recently).

Example:

[spoiler][code]Lab is a room.

A red ball and a blue ball are things in Lab.

The rat is an animal in Lab.

Persuasion rule for asking the rat to try doing something:
persuasion succeeds.

After reading a command:
say “(I just read a command! It was '[the player’s command][quotation mark]!)[command clarification break]”.

Test me with “x ball / red / x ball / get blue ball / drop ball / x / blue / x / get red ball / drop red ball / rat, get ball / red / rat, drop red ball / rat, get / red”.[/code][/spoiler]

There’s definitely a parser bug. The disambiguation behavior for a “What do you want to get?” question is not as smart as that for a “Which do you mean, …?” question. Filed bug inform7.com/mantis/view.php?id=1134.

(Why are they different? No good reason. They’re handled at two different places in the code, and one of the places was upgraded with some smarter behavior while the other was not. Looks like this happened way back in the I6 era.)

Thanks for the help, Zarf and everyone. And yikes on the bug discovery - I was really hoping this was just something beyond my experience. Well, so it goes.

I came across a similar problem with disambiguation here and have since cooked up a small extension that might help out. This will allow you to bypass disambiguation whenever you need to, like so.

After asking which do you mean (this is the bypass disambiguation rule): if (whatever), bypass disambiguation.

You will need to use an “after asking which do you mean” rule in order to bypass disambiguation. However once set up, it should work quite nicely.

Hope this helps.
Bypass Disambiguation.i7x (11.4 KB)

Interesting - thank you!

Bumped for extension awesomeness. I hope/am 90+% sure this is kosher?

Because it seems to work great for me so far in basic cases! I’m using it to hide disambiguation while hinting.