I came across this post: Intercept parser errors - #15 by Angstsmurf
When I add a similar rule, it seems to solve the problem where trying to take things from a carried container never works. (I’m using 6M62, in case that matters.)
Here’s what I have now, and at first glance it seems like it’s doing most of what I want:
[A rule from this thread: https://intfiction.org/t/intercept-parser-errors/46730/15]
Rule for deciding whether all includes things enclosed by the person reaching 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.
Plural-taking is an action applying to one visible thing.
Understand "take [things]" and "get [things]" as plural-taking when (the player's command matches the text "knives") or (the player's command matches the text "forks") or (the player's command matches the text "spoons").
Definition: an object is plural-matched if it is listed in the multiple object list.
Check plural-taking when the multiple object list is empty:
try taking the noun instead.
A multiple action processing rule when the current action is plural-taking (this is the taking duplicate items rule):
let potential sources be a list of objects;
let reachable outside-the-player sources be a list of objects;
let unreachable outside-the-player sources be a list of objects;
let reachable in-inventory sources be a list of objects;
let sample item be entry 1 in the multiple object list;
repeat with item running through the multiple object list:
let H be the holder of the item;
add H to potential sources, if absent;
if (H is not the player) and (H is not enclosed by the player):
if H is a closed container:
add H to unreachable outside-the-player sources, if absent;
otherwise:
add H to reachable outside-the-player sources, if absent;
otherwise if H is enclosed by the player:
if H is a supporter or H is an open container:
add H to reachable in-inventory sources, if absent;
[If there are reachable items outside the player's inventory, ignore the stuff in the player's inventory:]
if reachable outside-the-player sources is not empty:
let revised source list be a list of objects;
add reachable outside-the-player sources to revised source list;
add unreachable outside-the-player sources to revised source list;
now potential sources is the revised source list;
now reachable in-inventory sources is { };
[now unreachable in-inventory sources is { };]
if the player is listed in potential sources:
[if all available items are directly carried by the player, reject the attempt to take]
if the number of entries in potential sources is 1:
say "The only [printed plural name of sample item] you see are ones you already have.";
now potential sources is { };
[if there are other options besides direct inventory, remove direct inventory from consideration:]
otherwise:
remove the player from potential sources;
[If there is more than one open holder in inventory, ask the player to be more specific.]
say 1;
if the number of entries in reachable in-inventory sources > 1:
let sample source be entry 1 in reachable in-inventory sources;
let all-caps source be "[sample source]" in upper case;
say "There are [printed plural name of sample item] available from [reachable in-inventory sources with definite articles], and I'm not sure which ones you want. You could try, for example, TAKE [printed plural name of sample item in upper case] FROM [all-caps source].";
remove reachable in-inventory sources from potential sources, if present;
now reachable in-inventory sources is { };
[Since we're already spelling out the options rather than choosing one, also report on any containers that are closed at this time:]
repeat with given holder running through potential sources:
if the given holder is a closed container:
let count be the number of plural-matched objects in the given holder;
[let capitalized count be "[count in words]" in title case;]
say "[line break]There [regarding count][are] also [if count is 1][a sample item][otherwise][printed plural name of sample item][end if] in [the given holder], but [the given holder] [are] closed.";
now potential sources is { };
otherwise if the number of entries in reachable in-inventory sources is 1:
say 2;
repeat with given holder running through reachable in-inventory sources:
repeat with item running through the multiple object list:
if the holder of the item is the given holder:
say "[item]: [run paragraph on]";
silently try taking the item;
if the player carries the item:
if (the given holder is a container) or (the given holder is a supporter):
say "You take [an item] from [the given holder].";
otherwise:
say "You take [an item].";
now potential sources is { };
[Next we take any takeable items from sources outside of inventory:]
say 3;
repeat with given holder running through reachable outside-the-player sources:
repeat with item running through the multiple object list:
if the holder of the item is the given holder:
say "[item]: [run paragraph on]";
silently try taking the item;
if the player carries the item:
if (the given holder is a container) or (the given holder is a supporter):
say "You take [an item] from [the given holder].";
otherwise:
say "You take [an item].";
remove reachable outside-the-player sources from potential sources, if present;
[Now report on any remaining closed containers: closed containers inside the inventory if there were no open ones in the inventory, and all closed containers outside inventory:]
say 4;
repeat with given holder running through potential sources:
if the given holder is a closed container:
let count be the number of plural-matched objects in the given holder;
say "[line break]There [regarding count][are] [if count is 1][a sample item][otherwise][printed plural name of sample item][end if] in [the given holder], but [the given holder] [are] closed.";
alter the multiple object list to { }.
To say take-the-forks:
say "You're not [if the player encloses a fork]directly [end if]carrying any forks. If you want to do something with the forks as a group, try taking them first".
To say take-the-knives:
say "You're not [if the player encloses a knife]directly [end if]carrying any knives. If you want to do something with the knives as a group, try taking them first".
To say take-the-spoons:
say "You're not [if the player encloses a spoon]directly [end if]carrying any spoons. If you want to do something with the spoons as a group, try taking them first".
Understand "put forks in/into/inside/on/onto [text]" as a mistake ("[take-the-forks].") when (the player does not carry a fork) and (two forks are visible).
Understand "put [text] forks in/into/inside/on/onto [text]" as a mistake ("[take-the-forks].") when (the player does not carry a fork) and (two forks are visible).
Understand "put knives in/into/inside/on/onto [text]" as a mistake ("[take-the-knives].") when (the player does not carry a knife) and (two knives are visible).
Understand "put [text] knives in/into/inside/on/onto [text]" as a mistake ("[take-the-knives].") when (the player does not carry a knife) and (two knives are visible).
Understand "put spoons in/into/inside/on/onto [text]" as a mistake ("[take-the-spoons].") when (the player does not carry a spoon) and (two spoons are visible).
Understand "put [text] spoons in/into/inside/on/onto [text]" as a mistake ("[take-the-knives].") when (the player does not carry a spoon) and (two spoons are visible)
[I was trying to give a more helpful message than "You can't see any such thing" in these cases, but this code never seems to run:]
Understand "take [something] from [something]" as a mistake ("You don't see any such thing in [the second noun].") when the second noun is a container and the noun is not in the second noun.
Understand "take [things inside] from [thing]" as a mistake ("You don't see any such thing in [the second noun].") when the second noun is a container and the noun is not in the second noun.
Understand "take [thing] from [thing]" as a mistake ("You don't see any such thing on [the second noun].") when (the second noun is a supporter) and (the noun is not on the second noun).
Understand "take [things] from [thing]" as a mistake ("You don't see any such thing on [the second noun].") when (the second noun is a supporter) and (the noun is not on the second noun).
[This also doesn't work:]
[Check removing something from something when the second noun is a container and the noun is not in the second noun:
say "You don't see [the noun] in [the second noun]." instead.]
[Check removing something from something when the second noun is a supporter and the noun is not on the second noun:
say "You don't see [the noun] in [the second noun]." instead.]
A fork is a kind of thing.
A knife is a kind of thing.
A spoon is a kind of thing.
A doodad is a kind of thing.
Lab is a room.
An aquarium is a closed transparent container in Lab.
7 spoons are in the aquarium.
A sink is a fixed in place container in Lab.
A rug is an enterable supporter in Lab.
A table is a supporter in Lab.
A plate is a portable supporter on the table.
A box is a container carried by the player.
5 forks are in the box.
5 knives are in the sink.
5 spoons are in the box.
9 doodads are in the box.
Every turn:
say italic type;
say "Spoons carried directly: [number of spoons carried by the player][line break]";
say "Spoons in box: [number of spoons in box][line break]";
say "Spoons in sink: [number of spoons in the sink][line break]";
say "Spoons on plate: [number of spoons on the plate][line break]";
say "Spoons in aquarium: [number of spoons in aquarium][line break]";
say roman type.
Test me with "i / put spoons in sink / take spoons / take spoons / put 2 spoons in box / put 2 spoons in sink / put 2 spoons in sink / take spoons / take 2 spoons from box / put 2 spoons on plate / take plate / put 3 spoons in box / take spoons / take spoons from plate / take spoons from sink ".
Feel free to point out anything that’s not working, dangerous, etc.
(I hear what you’re saying, OtisTDog, about addressing the root cause, but I’m not really sure how to do that.)
EDIT:
I’m editing way after the fact because there was a “like” on this post. I think I ended up having to make more changes to this code after doing some more testing. One thing was building in an exception for if a player uses numbers in a command–for example, “take 2 forks.” So if anyone decides to use some of this code, you should probably test that.
Another edit:
The text matching part should probably also say “case insensitively” to deal with players typing “SPOONS” instead of “spoons,” and so on.