Taking Multiple Items

Hey guys,

New forum member! :slight_smile:

So i’ve had a browse through the existing threads on this forum to help me with most of my issues so far but i have one question i’m unable to fathom out so forgive me if this has been asked/dealt with already. I apologise if so.

Is there anyway to define a difference in taking one item to taking several?

What I mean is let’s say I have 4 banana’s on a table.

By default…
if I type “take banana”, it says “taken!”.

if i type “take 3 bananas”, it says:

Banana: Taken
Banana: Taken
Banana: Taken

If I try and customize the “take” text using “Instead” or “Report”, it says the same thing 3 times, for example:

Take 3 bananas
Banana: You reach out and pick up the banana.
Banana: You reach out and pick up the banana.
Banana: You reach out and pick up the banana.

is there anyway of telling inform to say something ELSE if picking up more than 1 of a group of objects?

So if I say “take 3 bananas”, instead of repeating taking one banana 3 times, it says “You grab a bunch”

I’m sure there is. There has to be! lol it’s just eluding me!
Many thanks for the assistance though. :slight_smile:

Hmm, not sure if my wording has stumped you all or if its harder than I first thought.

I think in essence what I am wondering is if theres a way to define an “instead” rule for ONE object while having a seperate “Instead” rule for when “x amount” is also supplied.

For Example, I’ve tried something like:


The plural of banana is bananas.

Five bananas are in the Kitchen.

report taking a banana:
      say "You reach out and grab a banana" instead.

report taking bananas:
     say "You grab a bunch of bananas" instead.

That doesn’t work though.
It still says the first report 3 times if I instead specify an amount.

A good place to look for questions like these is the Recipe Book. Under Section 6.15, Commands -> Actions on Multiple Objects, you’ll find some discussion of the issue and a link to example 420, which has such a situation worked out in code.

Thanks for offering some assistance. :slight_smile:

Unfortunately however, unless im severely misunderstanding that chapter, that just seems to be explaining how to create a list of objects that can be handled through an action, such as “take”.

That however still results in 5 lines of “banana: taken” if I take 5 bananas.

What I want to know, I guess, is a way of truncating that kind of display down to a sentence.

So INSTEAD of saying:

it says

It’s not at all simple (as you’ll see when you look at example 420). When you’re performing an action on multiple items, Inform makes a list of everything you’re taking (called the “multiple object list”) and goes through separately performing the action on each item (with a little bit of text before each action that’s performed). So it’s never performing an action that it understands as “taking [multiple] bananas”; it’s “taking a banana” three times.

To change the behavior (unless I’m missing something) you’d have to set a check on the multiple object list to see if it contains more than one banana, change the behavior for reporting taking a banana so that it only prints something for one banana per turn (and says “You grab a bunch of bananas” if you’ve successfully taken more than one), change the rule for printing things like “banana:” so it prints “three bananas:” for one of the bananas and doesn’t print anything for the rest of the bananas, worry about what happens if you don’t succeed in taking some of the bananas for some reason, and figure out what to do if you, say, took one banana from the room and two bananas from on top of a table. I might be able to work up some code for this given time, but I have some formal epistemology/semantics to work on for my day job and frankly that seems like it might be simpler.

[In example 420, “the selectively announce items from multiple object lists rule” is the rule that makes sure “banana:” doesn’t get printed a bunch of times, and the rest of the text output is handled by a new action called multiply-giving. You probably can’t do something quite analogous for your example, because you’ll want the taking action to respect all the usual logic of taking, while reporting it differently.]

Example 284, which does more or less the same kind of thing, may also prove useful.

wow! lol I honestly didn’t think it would be as complicated as all that!!
In actuality I don’t wish to customize the text for a group of things, more just for when your taking only one of a group.

So for example, this gives you:

While this gives you:

So in essence it reverts back to default Inform text if the amount trying to be taken exceeds the single one.
At the moment though, because of the “Report” rule for “taking a banana” it would say

is that still just as complicated an issue?

Do you mean like this?There is a room. A banana is a kind of thing. Here are three bananas. Report taking a banana when the multiple object list is empty: say "Custom message here."; rule succeeds. Test me with "take banana/take two bananas".

Yes! that is it! Perfect! :smiley:

Now, lol what does it mean? :stuck_out_tongue:

Just trying to work out how it does it.

EDIT: wait, I think I get it now.

“when the multiple object list is empty” means your not specifying multiple objects.
Pretty much what i was looking for!!

I’m still getting to grips with Inform terminology.

Thanks for that though! Great help! :slight_smile:

The standard rules actually already implement this for the putting it on and inserting it into actions, like so.

[code]Report an actor putting something on (this is the concise report putting rule):
if the actor is the player and the I6 parser is running multiple actions,
stop the action with library message putting it on action number 7
for the noun;
otherwise continue the action.

Report an actor putting something on (this is the standard report putting rule):
if the actor is the player, issue library message putting it on action
number 8 for the noun;
otherwise issue actor-based library message putting it on action
number 9 for the noun.

Report an actor inserting something into (this is the concise report inserting rule):
if the actor is the player and the I6 parser is running multiple actions,
stop the action with library message inserting it into action number 8
for the noun;
otherwise continue the action.

Report an actor inserting something into (this is the standard report inserting rule):
if the actor is the player, issue library message inserting it into action
number 9 for the noun;
otherwise issue actor-based library message inserting it into action number 10 for the noun.[/code]

So you should be able to use this.

[code]First report taking when the I6 parser is running multiple actions (this is the concise report taking rule): say “Taken.”.

Report taking a banana (this is the report taking a banana rule): say “You quickly look left and right before quickly pocketing a banana.”.[/code]

Hope this helps.

EDIT - This form doesn’t quite work, see later post for corrected version.

That doesn’t seem to work – in fact I can’t figure out what the concise report inserting rule does, or when “the I6 parser is running multiple actions” is true.

That’s because I messed up slightly. It should be like this.

[code]First report taking when the I6 parser is running multiple actions (this is the concise report taking rule):
say “Taken.”;
rule succeeds.

Report taking a banana (this is the report taking a banana rule):
say “You quickly look left and right before quickly pocketing a banana.”;
rule succeeds.[/code]

The “I6 parser is running multiple actions” variable is true when “multiflag” is true.

The concise reporting rules are designed to give a shorter message when taking many items at once so that you don’t get a huge amount of text printed at once.

You can see the concise reporting rules in action here.

[code]“Test”

First report taking when the I6 parser is running multiple actions (this is the concise report taking rule):
say “Yoink!”;
rule succeeds.

First report dropping when the I6 parser is running multiple actions (this is the concise report dropping rule):
say “Shplonk!”;
rule succeeds.

Report taking a banana (this is the report taking a banana rule):
say “You quickly look left and right before quickly pocketing a banana.”;
rule succeeds.

Report dropping a banana (this is the report dropping a banana rule):
say “Nonchalantly, you drop a banana.”;
rule succeeds.

The Testing Room is a Room. The chest is a fixed in place container in the testing room. The table is a supporter in the testing room.

A banana is a kind of thing. There are 5 bananas in the testing room.

Test rules with “rules on / test me / rules off”.

Test actions with “actions on / test me / actions off”.

Test me with “take a banana / put banana on table / take banana from table / put banana in chest / take banana from chest / take all / put all on table / take all / put all in chest / take all / drop all”.[/code]

Hope this helps.

Thanks. My problem was that, when I tried to test the concise putting on rule, I tested wearing a bunch of things instead of putting a bunch of things on something else. Whoops.

The wearing action doesn’t accept multiple items by default, so it won’t need a concise reporting rule. However, it’s best to add one if the wearing action (or any other action for that matter) is modified to accept multiple items.

Yup – I just completely spaced out that “put on shirt” was not the putting on action.

Another point on taking multiple items. Consider this.

[code]“Test”

The Testing Room is A Room. An item is a kind of thing. There are 50 items in the testing room.

Test me with “take all / drop all”.[/code]

It would be a lot better if identical items were reported together like this.

>take all 50 items: Taken!

That way you don’t get a huge amount of text printed saying exactly the same thing.

There is an extension that does this: Consolidated Multiple Actions by John Clemens.

(It’s not perfectly up to date – you need to go into the source and change “[The actor]” to “[The person asked]” at several places.)