"Instead of X, try verbing all..." possible?

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…

1 Like

How about:

Instead of emptying a container:
	now all the things in the noun are in the location. [or nowhere]

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.

>empty crate
foo: Taken.
bar: Taken.
baz: Taken.

1 Like

I was planning to call that action “dumping”, “dumping into”, and “dumping onto”. Then “emptying” would just be “dumping into the actor”.

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.

2 Likes

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.

The result is identical.

3 Likes

Not always identical. ArdiMaster’s version triggers TAKE actions (and thus abides by check/before/after/report rules).

1 Like

Which can easily be done:

Carry out emptying:
	repeat with item running through things in the noun:
		say "[item]: [run paragraph on]";
		try taking item.

The only difference here is the paragraph break instead of a line break between each take response.