I wanted to create an emptying action. I thought it might be as simple as:
Emptying is an action applying to one visible thing.
Understand "empty [something]" as emptying.
Instead of emptying a container, try removing all from the noun.
But it “didn’t recognize ‘removing all from the noun’.”
I also tried things like try removing the list of things contained by the noun from the noun. But it also didn’t work.
I can get it working by manually running through all the items:
Carry out emptying a container:
let L be the list of things contained by the noun;
repeat with item running through L:
try silently removing item from the noun;
say "[item]: Taken.[line break][run paragraph on]";
say "".
But I’d much rather be able to defer to the underlying multiple objects system. Is there any way to handle this more cleanly?
Edit: Also, I’m guessing there’s a better way to do the say "". part…
I don’t think you can officially make a multiple action happen in your code, but you can emulate the effect with some I6 hackery:
"Emptying"
The lab is a room.
The crate is a container in the lab.
The foo, the bar, and the baz are in the crate.
Emptying is an action applying to one visible thing.
Understand "empty [thing]" as emptying.
To multi-take (OS - description of things):
(- @push multiflag; multiflag = true;
objectloop({-my:1} && {-matches-description:1:OS}) {
RunParagraphOn();
BeginAction(##Take, {-my:1}, nothing, {-my:1});
}
@pull multiflag;
-).
Instead of emptying a container:
multi-take the things in the noun.
This would produce:
lab
You can see a crate (in which are a foo, a bar and a baz) here.
The reason you can’t do the thing it seems like you should be able to do is because actions only deal with zero, one, or two nouns. A noun could refer to multiples of the same thing, c.f. Duplicates, but never different things. So when you take all, a loop occurs in the parser that separately invokes the take action on the applicable objects. The code below demonstrates their separateness (if you take all).
Lab is a room.
take-count is initially 0.
before taking something: increment take-count; say "Take [take-count].";
A tennis ball is in the lab. A spy decoder ring is in the Lab.
So the underlying multiple objects system exists in the parser; a rule in an action rulebook couldn’t make use of it.
It can be done just as easily without resorting to I6:
"Emptying"
The lab is a room.
The crate is a container in the lab.
The foo, the bar, and the baz are in the crate.
Emptying is an action applying to one visible thing.
Understand "empty [thing]" as emptying.
Carry out emptying a container:
repeat with item running through things in the noun:
say "[item]: Taken.[line break]";
now the player carries item.