I7: only warn against taking multiple items once

[code]before taking:
if the number of entries in the multiple object list is greater than 1:
say “You try to take the [noun], but no dice. Maybe you should pick things up one at a time.”;
reject the player’s command;

room 1 is a room. the box is in room 1. the cat is in room 1. the dog is in room 1.
[/code]

So I had the code above. I want to restrict the user from taking more than 1 item. And I want to have the “You try” command appear once, but instead, it appears three times. That’s only cosmetic, so it’s no big deal, but…

On the other hand, another almost-solution is:

[code]this is the hoarding rule:
if player is in room1:
if word number 1 in the player’s command is “get” or word number 1 in the player’s command is “take”:
if the number of entries in the multiple object list is greater than 1:
let Q be entry 1 of the multiple object list;
say “You try to take the [Q], but [if Q is plural-named]they roll[else]it rolls[end if] away. Maybe you should pick things up one at a time.”;
stop the action.

The hoarding rule is listed before the generate action rule in the turn sequence rules.[/code]

Again, this works, but I only want to reject things for “take,” and if I try to gauge the current action, it’s waiting. I am thinking there has to be a better way than the “if word number 1 is…” because that seems like it could maybe cause the parser problems.

Any suggestions? Thanks!

If you’re working in 6M62, perhaps the natural way to do this is in the multiple action processing rulebook. Maybe like this:

[code]Block multiple taking is a truth state that varies.

A multiple action processing rule when the current action is taking and the number of entries in the multiple object list is greater than one: [the last clause is there to allow TAKE ALL FROM OVEN when there’s only one thing in the oven]
now block multiple taking is true;
let L be the multiple object list;
truncate L to 1 entry; [so the block message only gets printed once]
alter the multiple object list to L.

Before taking when block multiple taking is true:
now block multiple taking is false; [reset the flag]
say “You can only take one thing at a time.” instead.[/code]

My Actions on Groups extension is designed to give graceful outputs for various multiple-object action cases, but you probably don’t need it in this case (also it’s not updated to play nicely with the multiple action processing rules).

Oh, wow, right! I suppose I could just alter the multiple object list, too. That works. Thanks, Matt!

I’ll also have a look at your extension. Even if I don’t use it, it’ll be cool to see some coding details I can learn from.

I spent a lot time on this in Counterfeit Monkey. There are hundreds of objects you can carry in that game, and sometimes you could get hundreds of lines like “Y-remover: The bed can’t contain things” repeated for every object in your inventory.

It isn’t enough to stop after the first one, either. If I type PUT ALL IN BED, I don’t want the reply to be “Y-remover: The bed can’t contain things”. The mention of the Y-remover makes no sense.

My solution is very ugly, but it works. Basically it is a lot of checks to make sure that we never reach the repeated multiple object action if we are not going to allow it anyway. For every check that prevents the player from, say, inserting a single thing into the toolkit, there is a corresponding check to prevent the player for inserting multiple things into the toolkit. It is not quite as bad as it sounds, but almost.

After I had made all that work properly, I found out about the Actions on Groups extension and had a brief look at it, but couldn’t see any obvious way to adapt my code to it.

Feel free to have a look and make improvements. The relevant stuff starts at line 61.

https://github.com/i7/counterfeit-monkey/blob/master/Counterfeit%20Monkey.materials/Extensions/Counterfeit%20Monkey/actions%20on%20multiple%20objects.i7x