Inventory reveals a hidden object

In this example I have a box of cards. There is a letter hidden inside it. The player must examine the box to reveal the letter. But it can be revealed by doing an inventory.

Study the screenshot to see what I mean. Would the concealed attribute keep the letter hidden until the box is examined? If not, how do I get around this?

concealed can’t hide anything in your inventory.

To make the letter hidden until the player examines the box, I would keep the letter in limbo until the player examines the box, then move the letter to the box, like:

Object Box "box"
  with
    description [;
      if(Letter in nothing) {
        move Letter to self;
        scope_modified = true; ! Only needed if OPTIONAL_MANUAL_SCOPE is defined
      }
      print "The box is made of black oak. It ";
      if(PrintContents("contains ", self) == false)
        print "is empty";
      ".";
    ],
   ...
2 Likes

Great, thanks! I looked at my code and realised I was already using concealed. Here is my code:

Object -> WhiteBox "white playing card box"
	with name 'white' 'box' 'small' 'playing' 'card',
	description "Suitable for storing cards.",
    after [; Examine:
       if (LetterBox in self)
          move LetterBox to SecretRoom;
          "Inside the box is a folded letter.";
    ],
	has concealed container openable open;

Object -> -> LetterBox "folded letter"
	with name 'letter' 'folded',
	description "The letter has handwritten instructions for playing various card games.",
    has concealed scored;

Yes, that will work just as badly, if the player picks up the box containing the letter. Concealed doesn’t stop items in the player’s inventory from being shown.

I get the feeling that you are trying to use old-school techniques that aren’t necessary in modern authoring systems. Contrary to the advice given to you in another thread, you very rarely ever need to use concealed. Instead, use the technique that @fredrik gave above, i.e. test to see if the object is in nothing and make it appear if it is. I use this a lot. You can also use this if (say) you look under a mat to find a door key or take, move, push or pull the mat to reveal the same door key.

The only thing you need to be careful of is if the newly-found object can later be destroyed. If it can be destroyed and you can find it again, use remove object; and this will move it back to nothing. If it can be destroyed, but you cannot find it again (as would be the case after thowing the door key into the lake of lava), create a dummy room called limbo and move object to limbo; In this way, the test for nothing will fail and the object will not be recreated.

3 Likes

Thanks everyone for the help. I was not aware of nothing until now. I will use that from now on.

‘concealed’ rarely fully does what an author expects or intends, because concealed objects remain visible, in scope and interactive (in particular, they can be both examined and taken (although they are excluded from ‘take all’)). Which is often all OK as long as the player has no idea they are there, but may be undesirable if the player has acquired ‘out of game’ knowledge of their presence, e.g. in previous playthroughs. Hence the above-mentioned ‘hack’ of moving objects in-and-out of scope instead.

Keeping ‘concealed’ objects in scope was probably a bad design decision early in the history of Inform, now baked-in to Inform 6 to maintain compatibility with older games, but revised in Inform 7. Inform 7 uses the rather more apt adjective ‘undescribed’ for the I6 ‘concealed’ attribute, which for most authors will more closely match the actual rather than the anticipated behaviour.

Inform 7 also separately implements concealment (as a relation) such that concealed objects in I7 behave more as expected- i.e. when concealed they are invisible, out of scope and non-interactive- obviating the need to magically transport them in-and-out of scope. Furthermore, in I7 concealment is something bestowed upon an object by whatever it is held by, rather than a property of the object itself. So, removing something from a thing or person that conceals it will automatically render it unconcealed.

That said, it is still the case that a concealed (and/or undescribed) object is by default displayed in inventory in I7, presumably again a deliberate design choice of the Standard Rules since this default can be easily overridden so that concealed items are not listed. Presumably the general idea is that you’re more intimate with held objects, such that by default you’re aware of everything you’re carrying, including concealed objects, unless they’re in a closed, opaque container- although again, it’s easy in I7 to override this default behaviour so that even objects in closed, opaque containers are listed. However, this seems a little inconsistent- it might have been more intuitive to by default NOT list concealed objects in inventory- similar to the case with objects in closed, opaque containers- so that discovering them is by default a deliberate act rather than an accident of inventory. This is particularly the case as concealed objects in I7 remain out-of-scope even when listed, as happens by default, in inventory- such that an attempt to examine a concealed object just listed in inventory evokes 'You can’t see any such thing.", which is beginning to feel more like a bug than a deliberate design choice.

4 Likes