The difficult challenge of redirecting X for "take all from X"

The testing room is a room.

The player is wearing a suit.
The pockets are part of the suit. The pockets are a container.

A pen is a kind of thing. The player is carrying five pens.

Before inserting something into the suit:
	now the second noun is the pockets;
	try the current action instead.
	
Before removing something from the suit:
	now the second noun is the pockets;
	try the current action instead.

OK, let’s try it.

testing room

>put all in suit
pen: Done. [Five times]

>take all from suit
That can't contain things.

This is kind of unsurprising, I suppose. I guess the parser checks very early whether or not it makes sense to “take all from suit”. Indeed, with rules on, I can see not a single rule is processed before “That can’t contain things.” is generated. I’m trying to find workarounds but I’m not satisfied with any ideas yet:

  1. Make the suit a container so that this parses. I can’t get that to work - if I add “The suit is a container. In the suit is a doodah.” then I get “But it isn’t there now.” in response to “take all from suit”, which seems odd. This also feels like more of a kludge than I like.

  2. Simplify so the pockets aren’t an object, the suit is a container, and “pockets” is understood as the suit. This feels like giving up and I’m not ready to yet.

  3. Understand “suit” as the pockets and use “does the player mean” to make sure actions get directed to suit or pockets as appropriate. This is my favourite idea currently but this kind of solution makes me nervous; I always worry there will be a condition I didn’t think about when trying to cover things with “does the player mean”.

Better suggestions gratefully received.

I’ve been playing around with this example, and I found that before the problem you’re trying to solve, there is another problem. If the player is wearing the suit, even the command GET ALL FROM POCKETS doesn’t work (“There are none at all available!”). You’ll find that if you drop the suit, then GET ALL FROM POCKETS works, but still not GET ALL FROM SUIT.

So your problem is real when the game is aware of the suit, but something about that deeper level “multi-inside” programming that applies to (something) ALL commands (type TRACE before you do the failed GET ALL FROM SUIT to see it listed) means the pockets aren’t even being considered in the situation where the suit is worn. This means there’s no trick we can do there to redirect to the pockets. I’m not sure if there is some I6 tweak that can be done to get around that behaviour (likely chime-in point for another poster) but if there isn’t, methods you’d consider kludgier are possibly the way to go.

-Wade

Ok, I found an older topic on this forum pointing out a bug related to the behaviour you’re dealing with here. It’s been reported and something of a workaround was presented…

The workaround fixes the problem I reported, though not your pockets problem. However, it will now allow you to have a suit that’s a container into which you can PUT ALL and from which you can TAKE ALL, even when it’s worn. I think that’s a good start. See code below, which incorporates the fix:

The testing room is a room.

The player is wearing a suit. The suit is a container.

A pen is a kind of thing. The player is carrying five pens.

The exclude indirect possessions from take all rule is not listed in any rulebook.

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;

-Wade

Many thanks Wade @severedhand for this response. You discovering this other problem prompted me to remember I had already dealt with something similar, because I have another container the player holds, and already have an “exclude direct possessions” solution. With regard to suit vs. pockets, I played around a bit and discovered that the “does the player mean” solution works nicely and I think I’m going to trust it. So my solution is now:

The testing room is a room.

The player is wearing a suit.
The suit pockets are part of the suit. The pockets are a container. Understand "pocket" as the suit pockets.

Does the player mean doing something with the pockets: it is unlikely.
Does the player mean inserting into the pockets: it is likely.
Does the player mean removing from the pockets: it is likely.
Does the player mean searching the pockets: it is likely.

The exclude indirect possessions from take all rule does nothing when the item described is contained by the pockets and the current action is removing.

A pen is a kind of thing. The player is carrying five pens.

[The following is useful for testing.]
In the testing room is an ornament. In the testing room is a box. The box is fixed in place. The box is a container. A paperclip is a kind of thing. In the box are five paperclips.

P.S. sorry for the slow reply to your help - I thought I would have more time last weekend than I did.


Several edits to this post to add further code I later realised is necessary.

1 Like

Reviving this old thread… since I have ~the same problem, though I don’t think I can use the same workaround. (In my case, the thing that the player is likely to refer to and the container I’d like to redirect to have pretty different names.)

Is there some way to insert myself between where Inform decides on the second noun, and when it decides what “all” means?

Are you using the current version (10.1.2)? The first issue, created by things enclosed by the player being excluded from ‘all’ for remove actions, appears to have been fixed in Version 10.1.2.

If you are still on 9.3/6M62, writing this will solve that problem:

First for deciding whether all includes something enclosed by something held by the person asked when removing: it does.

As for the rest, here are 2 approaches that may help:

Approach 1 - using DTPM rules

The Lab is a room.

The player wears a suit. The pockets are a container incorporated by the suit. A pen and a watch are in the pockets.

action-to-be is an action name that varies. [we need this in order to talk about the current action before it's actually been finally decided upon]
The action-to-be variable translates into I6 as "action_to_be".

Understand "suit" as the pockets when (action-to-be is the removing it from action) or (action-to-be is the inserting it into action). [so that the parser will consider the pockets as well as the suit when removing/inserting]
Does the player mean removing or inserting when the second noun is the suit: it is very unlikely. [and when removing/inserting make sure it chooses anything other than the suit]
[it is expressed in this unusual way ('when the second noun is the suit') because a noun has not at this stage been officially incorporated into the current action (we're considering multiple possibilities). So, for example, 'removing something from the suit' doesn't work because the noun is nothing, and something can't be nothing.

Alternatives that do work are:

Does the player mean removing from the suit: it is very unlikely. [omitting the noun altogether allows it to be anything or nothing. But we can't write 'nothing' there]
Does the player mean inserting into the suit: it is very unlikely.

or

Does the player mean removing an object from the suit: it is very unlikely. [ this also works because 'an object' can be nothing, but something has to be some definite thing]
Does the player mean inserting an object into the suit: it is very unlikely.

Note that with these forms we can't combine inserting or removing in one condition because we need to include a preposition and it's different ('from' or 'into') in the two cases.
]

Test me with "take all from pockets/put all in pockets/take all from suit/put all in suit/remove suit/take all from pockets/put all in pockets/take all from suit/put all in suit/drop suit/take all from pockets/put all in pockets/take all from suit/put all in suit".

Approach 2 - make the parser understand “suit” to be the suit or the pockets according to whether we are removing/inserting or not:

The Lab is a room.

The player wears a suit-object [suit-object so that 'suit' only matches the suit when we say it does] with printed name "suit"[so that the suit-object appears as 'suit' in printed text]. The pockets are a container incorporated by the suit-object. A pen and a watch are in the pockets.

action-to-be is an action name that varies. [we need this in order to talk about the current action before it's actually been finally decided upon]
The action-to-be variable translates into I6 as "action_to_be".

Understand "suit" as the pockets when (action-to-be is the removing it from action) or (action-to-be is the inserting it into action). [so that the parser considers only the pockets when we type 'suit' in a command to insert or remove something]
Understand "suit" as the suit-object when (action-to-be is not the removing it from action) and (action-to-be is not the inserting it into action). [so that the parser considers only the suit when we type 'suit' in a command to do anything other than insert or remove something]


Test me with "take all from pockets/put all in pockets/take all from suit/put all in suit/remove suit/take all from pockets/put all in pockets/take all from suit/put all in suit/drop suit/take all from pockets/put all in pockets/take all from suit/put all in suit".

Thank you, that’s very helpful!

If I understand the general point correctly: it’s not possible to change the second noun before the first noun is determined, but we can emulate that by defining our “understand” lines carefully so that certain phrases will only be understood to mean the “pocket” when removing it from. AFAICT that’s not a totally hermetic solution – eg. I’m not sure it catches stuff like examine suit. put all in it. – but it’s certainly much better than anything I’ve found so far!