Player's holdall and the "handled" property

I have some objects that score points when they are handled for the first time:

After taking a book when the book is not handled: say "Taken."; increase the score by 1;

This has been working just fine. Now I have added a holdall to the game:

[code]The carrying capacity of the player is 5.

The backpack is a player’s holdall. The description of the backpack is “This is your purple backpack that you take to school every day.” The backpack is wearable.[/code]

What I’ve found is that if I put a book into the backpack (or Inform puts it there automatically), when it’s taken out of the backpack again, the player scores a point. It’s like the act of putting the book into the holdall is resetting the “handled” property.

Am I missing something obvious with how the holdall and the “handled” property interact? I guess one way around this is to change my “after taking” rule to check if the book is already in the backpack, which means the player has already had to touch it and thus scored the point.

If an object goes directly from the floor to a container, it won’t set “handled”. Does that explain what you’re seeing? The object will only score once, but perhaps not the first time it enters the player’s possession.

I had a play around with your little code snippet. I assumed you made ‘book’ a kind of thing. In that case when you say “after taking a book when the book is not handled”, I think Inform doesn’t realise that the first book you’re talking about is the same as the second.

This works just fine:

After taking a book when the noun is not handled: say "Taken."; increase the score by 1.

Yes, book is defined as a kind of thing.

A book is a kind of thing. Understand "book" as a book. A book has some text called title. A book has some text called author. A book is either scanned or unscanned.

Sure enough, you were right. When I changed my “before taking” rule to use “the noun” it now works as I expected.

Thanks for the quick replies!

You might still run into Zarf’s problem if you have a situation like this:

[code]Test is a room.

A book is a kind of thing.

There is one book in Test.

After taking a not handled book:
increase the score by 1;
continue the action;

The carrying capacity of the player is 5.

The backpack is a player’s holdall. The description of the backpack is “This is your purple backpack that you take to school every day.” The player wears the backpack.

Test me with “put book in backpack/take book”[/code]

You can fix that like this:

Last after taking something: now the noun is handled; continue the action;
If you make both rules into “carry out” rules, you don’t need to say “continue the action,” but whatever you do, you have to make sure the rules fire in the right order.

Ah, thanks for that! I hadn’t played with the ‘put’ command so I didn’t realize that was what Zarf was referring to. I think I’ve got it working now, thanks again!