When you say “in this situation,” it sounds like you mean the specific pencils contained by a cup carried by the player
scenario that you provided. The general case is things contained by a container enclosed by the player
, which can’t be addressed by any specific features of the objects to be manipulated. You can keep trying to generate special cases, but it might be better to try to get at the root causes.
As you note, the “general case” in the previous paragraph is not exhaustive, because there can be more objects in scope that are identical to the enclosed items, and you want the behavior to prefer not-enclosed items. (Good news: That’s the default, effectively, by virtue of the enclosed ones being discarded when deciding whether all includes
.)
You also mention the possibility of a response to >TAKE PENCILS that would prompt the player to revise the command to, e.g., >TAKE PENCILS FROM CUP versus >TAKE PENCILS FROM DRAWER. That would require a different understanding of the world by the parser than the template logic currently allows – not impossible, but a rewrite/expansion of some deep code.
Your phrase “as little hassle as possible” is a bit non-specific. Perhaps it would be helpful to construct a scenario of comparable complexity to that in your game and provide a transcript of the ideal behavior as you see it. The effort might (as it did for me) make some of the complications involved clearer.
In the meantime, to help make the problems more tractable, I’m pretty sure that the following deciding whether all includes
rules replicate the underlying I6 template logic in its entirety (though as zarf notes in the other thread it would take exhaustive testing to prove that out):
Rule for deciding whether all includes something undescribed (this is the undescribed things are not included in all rule):
it does not.
Rule for deciding whether all includes something worn by the person reaching (this is the worn things are not included in all rule):
it does not.
Token type is a kind of value. The token types are noun token, held token, multi token, multiheld token, multiexcept token, multiinside token, creature token, special token, number token and topic token. [The ID for end tokens isn't contiguous and also isn't of interest here.]
To decide which token type is the current token context:
(- ((line_tdata-->(pcount-1))+1) -). [perhaps not generically reliable, but seems OK for this]
Rule for deciding whether all includes something (called item) when current token context is listed in {multiheld token, multiexcept token} and item is not carried by the person reaching (this is the only carried things can be included in all for certain tokens rule):
it does not.
Rule for deciding whether all includes (this is the generic all inclusion rule):
it does. [As least specific, this will be invoked only if no other rule catches the case. It will always supersede the template logic.]
By using >RULES ALL and/or adding telltale output to the rules above, you should be able to observe how the system works more easily and add/adjust rules as you like to suit your purposes.