Open container that you can't see inside in Inform 7?

0 votes
47 views
asked Sep 6 in Authoring by silentphantom

Hi, I'm trying to have a small object which is inside another object that the player can't see.
However when looked at in game the "container" object is shown as either (closed) or the player can see what's inside it.

Here is my code for the objects in question:

There is an object called a hat. a hat is wearable. a hat is opaque.

There is an object called a tiny key. a tiny key is inside a hat.

Before taking the hat:
    if the tiny key is in the hat or a tiny key is not on the player:
        move a tiny key to the bedroom;
        say "As you pick the hat up, a tiny key falls out of the hat and clatters on the floor."

In game it looks like this:

You can see a hat (in which is a tiny key) 

If I make the hat closed, then it shows it as:

You can see a hat (closed)

Which I feel gives away that there's something hidden in the hat. Is there a way to show no suffix as to whether the hat is a container or not?

Another small question I had relates to moving the key to the same location as the hat. Obviously the current design of the puzzle means that attempting to move the hat would cause the key to drop, but what if I wanted the code to recognise what room the hat is in and then transport it's contents to that same room?

Thanks!

2 Answers

0 votes
answered Sep 7 by JasonLautzenheiser (16 points)
 
Best answer

Another way to hide the contents of the hat is the following:

Rule for printing the name of the hat: 
    say "[printed name of hat]";
    omit contents in listing.

The omit contents in listing, stops the printing of the "(in which is a tiny key)" phrase.

The second part of your question can really be done in two ways...

move the tiny key to the location of the hat.

will do just that.

You can also use

now the tiny key is in the location of the hat.

either one will work. I tend to use the "now" phrasing, but I don't know of any pitfalls to either.

0 votes
answered Sep 6 by eduardomezencio (36 points)

I think the best way to do this is to remove the following phrase:

a tiny key is inside a hat.

Then the key will be actually nowhere, and when you get the hat it will fall to the ground. It will work as if it were there, without you being able to see it. If you want the key to be visible when you examine the hat, you can move it there only after the player examines it. To make things like the (empty) disappear from the description of the room when the hat is a container, take a look at this chapter of the documentation:

ยง18.16. Printing room description details of something

  1. When it happens. When an item is listed in the miscellaneous collection of items present in a room (the ones which do not deserve
    their own paragraphs): this is normally the last paragraph of a room
    description.

To make the key appear in the location of the hat:

Move the tiny key to the location of the hat.
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...