Floating objects

How do I make an object which is in every room and the player cannot see it, but can take it?

That’s an interesting question. I’m not sure how the player will know that the object is present and takeable, if it’s not visible (that is, not being shown in the room description). That standard way to make an object that’s in every room is with a MultiLoc or a MultiInstance. You can read about these in Learning T3.

If the player can take your MultiLoc, you will need to write your own code for dobjFor(Take) so as to override the library’s verify() and check() routines. In the action() block you’ll need to basically get rid of the object’s location list.

A better alternative might be to create a second object (initially nowhere) that is a simple Thing. When the player tries to take the MultiLoc, get rid of it and silently swap in the single Thing that has the same printed name.

This strategy relates to my next question, which is, what happens after the player takes it? I assume it disappears from everywhere else … but then suppose the player drops it. Does it go back to being everywhere? You’ll want to think this through carefully.

Another alternative would be to make the object a Component of the player object. That way it will always be in scope, but will never be referred to in the room description. When the player takes it, make it not be a component any more. If the object is truly in every room in the game, this might be a better way to do it.

The object in question is an easter egg. The player is not meant to know it’s there.

In that case, make it a Component of the player object. You may also want to customize the actions it will or won’t respond to. For instance, if you want it to be takeable but not examinable, you could give dobjFor(Examine) a fake output that looks exactly like what the parser would respond if you tried to examine a nonexistent thing.

I was looking for something like inform’s foundin and concealed. If there’s anything like that.

Look at the Hidden and PresentLater classes (p. 25 of Learning T3).

Thanks. I will.