Intercept parser errors

You might want to take a look at multiple action processing rules, §6.15 in the documentation, before messing with the standard rules.

I will take that as a warning! I didn’t find anything useful in that part of the documentation, but I’ll look through it all again together with the advice here tonight.

Thanks again.

Thanks for all your ideas. Instead of a coat with a pocket, I have a hamper with compartments. Here is what I have currently. I hope this helps Andy and his coat pockets, and would be grateful to hear if you see any potential pitfalls.

So that the player can use “get all from hamper” to get all from its compartments:

Understand "take [things] from [hamper]" as multiple-removing.
Understand "get [things] from [hamper]" as multiple-removing.
Understand "remove [things] from [hamper]" as multiple-removing.
Multiple-removing is an action applying to two things.
Carry out multiple-removing:
	try removing the noun from the second noun;
	say "[run paragraph on]".

(Run paragraph on just makes it look neater until I find a better way.)

So that “all” only tries to take things in the hamper out of it:

Rule for deciding whether all includes things enclosed by a compartment when multiple-removing: it does.
Rule for deciding whether all includes things not enclosed by a compartment when multiple-removing: it does not.

So that the player can take things from a carried container:

Rule for deciding whether all includes things enclosed by the person reaching while taking or taking off (this is the new exclude indirect
	possessions from take all rule): it does not.
The new exclude indirect possessions from take all rule is listed instead of the exclude indirect possessions from take all rule in the for deciding whether all includes rulebook.

To replace the “[There] [adapt the verb are from the third person plural] none at all available!” message with something better:

Rule for printing a parser error when the latest parser error is the nothing to do error and the player's command includes "from hamper":
	if the hamper is empty:
		say "The hamper is empty." instead.

(Edited to add “or taking off” after “taking” in the rule.)

After taking the time to read all these excellent contributions to this discussion, I have come up with my own solution to the “little” scenario I created to test my coat / pocket idea. I actually wanted to have a coat be more of a kind - for example, a jacket is a coat, a raincoat is a coat. Every coat would have a pocket. This put some of the suggestions which relied on an actual coat a little difficult to apply but I think I have a useable model which for the most part does what I want. I have not tested all thoroughly though, so I may have missed some caveats :slight_smile: I have also made the boy persuadable and getting the boy to take all from jacket (or any coat) seems to work. Once again thanks for all the comments and help here.


“CoatTest” by AndyG

Instead of an actor inserting into a coat (called the target): try the actor inserting the noun into the pocket of the target instead.

Understand “take [something] from [a coat]” as pocket-removing.
Understand “take [things] from [a coat]” as multi-pocket-removing.
Understand “remove [something] from [a coat]” as pocket-removing.
Understand “remove [things] from [a coat]” as multi-pocket-removing.
Understand “get [something] from [a coat]” as pocket-removing.
Understand “get [things] from [a coat]” as multi-pocket-removing.

pocket-removing is an action applying to two things.

multi-pocket-removing is an action applying to two things.
first check an actor multi-pocket-removing:
try the actor removing the noun from the pocket of the second noun.

carry out an actor pocket-removing:
try the actor removing the noun from the pocket of the second noun.

A multiple action processing rule when the action name part of the current action is the multi-pocket-removing action (this is the strip-pocket rule):
let L be the multiple object list;
Let R be a list of objects;
repeat with O running through L:
if O is not in the pocket of the second noun:
add O to R;
remove R from L;
alter the multiple object list to L;
if L is empty:
say “[The second noun] is empty.”

To decide which object is the pocket of (item - coat):
Repeat with P running through things enclosed by the item:
if P is a pocket:
decide on P;

Rule for deciding whether all includes things enclosed by a person while taking (this is the new exclude indirect possessions from take all rule):
it does not.

The new exclude indirect possessions from take all rule is listed instead of the exclude indirect possessions from take all rule in the for deciding whether all includes rulebook.

Rule for deciding whether all includes things in a container while taking: it does not.

Rule for deciding whether all includes things on a supporter while taking: it does not.

A boy is in the cloak room. The boy is a male person.
A persuasion rule for asking the boy to try doing something: persuasion succeeds.

A nose is a kind of thing.
A nose is part of every person.

The cloak room is a room.

A vase is a container in the cloak room. In the vase is a flower and a stick.

A coat is a kind of thing. A coat is wearable. Understand “coat” as coat.

A pocket is a kind of container. A pocket is part of every coat. Understand “pocket” as pocket.

A raincoat is a coat. It is in the cloak room. Inside the raincoat’s pocket is a pen and a handkerchief.

A leather jacket is a coat. It is in the cloak room. Inside the leather jacket’s pocket is a penny and some fluff. The fluff is singular-named. The indefinite article of the fluff is “some”

Reminder to use the </> button when pasting code, otherwise it loses the indentation and gets jumbled in other ways.

You shouldn’t need to define the pocket-removing and multi-pocket-removing actions separately, though. Just define pocket-removing with the content of multi-pocket-removing and it will work for both.

You don’t need separate Understanding lines for single and multiple items, either.

Understand "take [things] from [coat]" as pocket-removing.

That works for one or more things.

Also, you might as well have pocket-removing redirect to taking without going through removing from.

Incidentally, do the multiple action processing rules show up anywhere in the index? I haven’t been able to find them. (Or the accessibility rules, for that matter.)

That’s what I said. :wink:

The accessibility rules is an undocumented rulebook – you’re supposed to put rules in the reaching inside rules, reaching outside rules, or visibility rules instead (which do appear in the Rules tab). Although there are a few things you can do more easily in that parent rulebook instead.

Multiple action processing is documented but it doesn’t seem to be listed anywhere in the Index. Not sure if that’s an omission or if it’s intentionally hidden for some reason.

I’ve amended my code accordingly.

Thanks everybody for your help.

Andy - Good luck!

1 Like

I believe you said that pocket-removing and multiple-pocket-removing could be the same action. I was referring to some of the code posted earlier, which looked like this:

Understand "take [something] from [coat]" as pocket-removing.
Understand "take [things] from [coat]" as pocket-removing.

Here, the first line is unnecessary.

Does example 216 (Waterworld) count? The example itself doesn’t really use the accessibility rules correctly, but it definitely uses one.

For that matter, the standard rules include exactly one accessibility rule. Why even use a rulebook unless the intent is to allow more of them?

You can replace the entire accessibility system by replacing that rule. But the topic is too complicated for the manual.

I have also amended my code and all seems to be working. Just a slightly off topic question (brought on by the answers in this thread) - I made the boy persuadable in my example and added some persuasion rules. One of the rules allows for the boy to give the player an item. If the boy does not have the item he attempts to take it (silently) before “giving”. Is there a way to stop a NPC from attempting the silent take and only “give” if they already have the item? Many thanks - AG

Just condition that particular persuasion rule on when the boy carries the widget.

Thanks, Gavin.

I tried adding this as suggested,

A persuasion rule for asking the boy to try giving something (called the item) to something (called the target) when the boy carries the item:
	persuasion succeeds.

But the boy still attempts to take the item if he does not have it?

I think I have found a way to get this to work.

The carrying requirements rule does nothing when asking the boy to try giving something to something. 

A persuasion rule for asking the boy to try giving something (called the item) to something (called the target):
	if the boy does not enclose the item:
		say "'I'm sorry, I don't have [those]?'";
		persuasion fails;
	persuasion succeeds.

This now seems to allow the persuasion rule to fire without the silent take so I can check if the boy has the item first.

Thanks - AG

This reveals something I hadn’t noticed about the carrying requirements rule: when you ask an NPC to do something that would trigger an implicit take, it is treated as you implicitly asking them to take.

>boy, give me the vase
[asking the boy to try giving the vase to yourself]
(the boy first taking the vase)
[(1) asking the boy to try taking the vase - silently]
The boy has better things to do.
[(1) asking the boy to try taking the vase - silently - failed]

[asking the boy to try giving the vase to yourself - failed the carrying requirements rule]

So an alternative to limiting the carrying requirements would be to have the NPC explicitly refuse to take things when asked.

Example
A persuasion rule for asking the boy to try taking:
	say "'Get it yourself,' says the boy.";
	persuasion fails.

A persuasion rule for asking the boy to try giving something held by the boy to:
	persuasion succeeds.

The block giving rule does nothing.

After jumping:
	try the boy taking the vase.

Then,

>boy, give me the vase
(the boy first taking the vase)
"Get it yourself," says the boy.

>jump
The boy picks up the vase.

>boy, give me the vase
The boy gives the vase to you.

A good example - Thanks, Dave. I amended my code to work like this and that works just as well. Not sure which (if any) is better but I quite like your solution so I will stick with that.

One other thing - Does anyone know how a NPC could be prevented from being persuaded to use “all” e.g “take all”, “drop all” but still allow persuasion of “take vase”, “drop pen” ?

This is hacky, but it works:

Rule for deciding whether all includes a thing when the person asked is Ethan: it does not.

In other words, “all includes nothing for this NPC”.

As a side effect, “Ethan, take all” will be interpreted as “answering Ethan that ‘take all’”, because it’s not a meaningful command when there’s no “all” to take. So:

Instead of answering Ethan that when the topic understood includes "all":
    say "Ethan scowls. 'I hate the word [']all['], and refuse to follow any instructions involving it. Try again.'"

Again, hacky, but it works.

Thanks for the Idea’s Daniel, this helped me come up with the following (which also seems to work).

A multiple action processing rule when the person asked is the boy:
	Alter the multiple object list to {};
	Say "'One instruction at a time please, I'm only small!'"