Ideas for getting around a TAKE ALL weirdness?

Hey all-

So I have a TAKE ALL problem. I have a chest with many things in it. The code is set up so that you only have to take one thing and then it automatically removes the rest of the things, because having to take 5 items individually is annoying. But the player has no way of knowing that I’ve been kind here, and will probably try TAKE ALL. Which is fine, except that getting the things out of the chest triggers an important thing to happen. And there are other things in the room that can be taken. So when you type GET ALL, this is what you get:

chest: You need to leave it here.

thing 1: You need to leave it here. (this, along with the chest, was previously put here by the player)

thing 2: You take things 2, 3, 4, and 5 out of the chest and arrange them on a table. (this will happen no matter what object you try to take out of the chest)

Now the important scene text is triggered. What’s bugging me about this is that extremely important text is sandwiched between the above stuff and below stuff.

thing 3: It’s where it needs to be. Leave it. (things 3, 4, and 5 were automatically taken out along with thing 2, so it’s now that the game triggers them as part of TAKE ALL, and I’ve set it up so they won’t try to carry them around, as they’re needed by an NPC.)

thing 4: It’s where it needs to be. Leave it.

thing 5: It’s where it needs to be. Leave it

I don’t want to turn off TAKE ALL, because it’s handy at various other times in the game. And I thought about turning it off just in this room, but it would annoy me to have the game say “Try taking one thing from the chest” when there are so many things there to take.

These things are all just scene flavor, and I also thought about lumping them together as one thing- like “supplies,” that you could just take as one thing. Which would certainly get rid of the problem. But I rather like the player seeing all these individual supplies in the chest on opening it.

Any ideas for a more graceful solution here? As it is, it’s really clunky, and I don’t like any of the ideas I’ve had for solving it.

2 Likes

Example 427, “Formicidae”, might be helpful here, as it’s about manipulating the order in which items are handled after TAKE ALL, so that the interesting object is handled last: 6.15. Actions on Multiple Objects

4 Likes

That is an extremely useful example. Thanks!

1 Like

ZIL had an option for cutting off all future actions if something important happened, and I think Inform 6 does too, but I don’t believe it’s exposed at the I7 level. It would be a useful feature for cases like this.

1 Like

The I6 parser interrupts the multiple-object loop if the player dies or if the player’s location changes. So that’s what “something important happened” means. I7 does the same checks.

Adding more checks is easy enough at the I6 level. In the I6 parser, this is the bit with the comment

                ! (c) generate a sequence of actions from the list
                !     (stopping in the event of death or movement away).

In I7 that comment doesn’t exist, but you can look for the GenerateMultipleActions() routine.

2 Likes

Perfect, that’s exactly what I was looking for. I’m going to experiment a bit and see how feasible/useful it would be to let authors “abort the action sequence” (ending multiple actions or multiple commands separated by THEN) in case of dramatic events.

In this case, putting the first chest item at the end of the multiple object list (and removing all the others from it, which you can do in the same way) is a better solution though.

2 Likes

OK, I’m just going to do what I do best and cheat here with an “After reading a command” rule in this room, with "if the player’s command matches “get all/take all” yada yada yada. Hopefully that won’t break Inform.

I’d suggest instead:

For deciding whether all includes a thing (called item)
  when the location is the room-name and
  (the item is thing 3 or the item is thing 4 or the item is thing 5) and
  the item is in the chest:
     it does not.

…maybe that should include something like and thing 2 is in the chest and thing 2 is not handled.

1 Like

I’m just not sure how this will work since I don’t know which item the player will take first. I guess I can make the player take only a specific thing first, but I’d rather not. Thing 2 could just as easily be Thing 5.

Honestly I think StJohnLimbo’s solution is the best one.

This is the rearrange items when taking all rule:
    let L be the multiple object list;
    let N be the number of entries in L;
    if N is greater than 1:
        remove the list of things in the chest from L;
        if the number of entries in L is less than N: [Something in the chest was included in ALL]
            add a random thing in the chest to L;
            alter the multiple object list to L.

The rearrange items when taking all rule is listed before the generate action rule in the turn sequence rules.

In other words, if an action is being performed on multiple objects, remove all things in the chest from the multiple object list. If anything was removed this way, add a random thing in the chest to the end of the list. Otherwise, don’t make any alterations and continue on (without saving our removals: the multiple object list goes completely unaltered).

2 Likes

Right, this seems like the best solution!

I suppose there’s the related problem where the player types like TAKE CANDLE AND WATCH, not TAKE ALL, but I’m not sure there’s an easy workaround for that one, and it’s even rarer anyway.

True, but in that case I think the behavior is still good, if taking anything from the chest automatically grabs all the others. The only oddity in that case is that the “object: Taken.” part will print the wrong object’s name.

You can get around that by noting one of the objects that’s in the chest and in the multiple object list before removing it, but working with lists in Inform is awkward enough that I didn’t bother.

1 Like

Good points.

from-chest is a kind of thing.


thing 1 is in the chest.
thing 2 is a from-chest.
thing 3 is a from-chest.
thing 4 is a from-chest.
thing 5 is a from-chest.
A from-chest has an object called the previous location.
Before taking a from-chest (called the item): now the previous location of the item is the holder of the item.

when play begins: now all from-chests are in chest.

To arrange is a verb.

This is the rearrange items when taking all rule:
    let L be the multiple object list;
    let N be the number of entries in L;
    if N is greater than 1 begin;
        remove the list of from-chests in the chest from L;
        if the number of entries in L is less than N begin;[Something in the chest was included in ALL]
            add a random from-chest in the chest to L;
            alter the multiple object list to L;
end if;
end if;

after taking a from-chest (called the item) when the previous location of the item is the chest and a from-chest is in the chest:
  let L be the list of from-chests in chest;
  repeat with x running through L begin;
    now the player carries x;
  end repeat;
  add the item at entry 1 in L;
  say "You take [L] and arrange them on the table.";

The rearrange items when taking all rule is listed before the generate action rule in the turn sequence rules.

This is a little awkward in terms of printing things like

thing 5: You take thing5, thing 4, thing 3, thing 2 and arrange them on the table.

but gets close.

[Edited: refined the after rule]

1 Like

Holy crap, that’s great. I can’t even imagine how much programming wizardry it takes to have modified “Formidicae” like that. I have doubts that I’ll ever get there. Works beautifully.

And probably everyone else knew this and was just waiting for me to discover it for myself, but you cannot override “take all” with an “After reading a command” rule. Inform does not want you to touch it there.

1 Like

It looks like you have a lot of command manipulation and rule revisions. I was thinking of a more (perhaps naive) solution. What if you made the things from-chest as a part of something, then taking the part brings out the whole thing, which you can manipulate in text to look like many things. Once the aggregate is out, you can break it down into many things and the aggregate is nowhere. Just a thought.

1 Like