Takeable item

Dear all,
there’s something I can easily do in Inform 6 but after a few humble tries I don’t know how to do it in Inform 7:
An object X shall have a detail Y that the player shall be able to examine - and take. X itself is takeable as well. So Y should be where X is, and invisible, as long as it hasn’t been taken; after that it shall be visible and a normal inventory item.
How do I achieve this?
Thanks and kind regards,

1 Like

There are probably several ways to do this, but from what you’ve said I think the one that best matches your intent is to start out with Y as part of X, and then write an “instead of taking the Y when Y is part of X” rule that moves the Y to the player’s inventory (since by default you can’t take something that’s part of another item, you need to use an instead rule).

EDIT: I corrected what I think is a typo in the thread title to make it easier to find later.


[Deleted - I did it wrong, the incorporated piece should be invisible.}

1 Like

Here’s some sample code. Let’s say the things in question are a fountain pen and its cap:

Lab is a room.

The pen is a thing in the Lab. The description is "Fountain pen."
The ornate cap is a thing. The description is "Filigreed cap."

Last carry out taking the pen for the first time: now the pen incorporates the ornate cap.

Last report taking the pen for the first time: say "[We] [take] notice of the pen's ornate cap.".

For printing inventory details of the pen: say " (with an ornate cap)".

It’s a variant on what Mike suggested. The cap begins the game out of play. You don’t want it in scope until the pen has been taken, and having something out of play is often the easiest way to ensure it’s out of scope.

The last thing that happens in Carry out taking it (for the first time) is that now it becomes a part of the pen, so you never have to worry about them getting separated or the cap not being in scope when the pen is.

I’m guessing taking it should also call attention to it, so I added a Report rule.

And parts of things aren’t mentioned in your inventory at all by default, so I added a rule to the printing inventory details of something activity to mention the cap.


With very few minor tweaks it worked! Thanks!!