Making objects invisible

Is there any way of making an object that is in the same room as the player invisible until something happens to make it visible?

What seems to be missing from Inform is a invisible property that makes an object invisible to the player.

Maybe there is a way to not have the object listed when the player types Look or enters a room that has the invisible object.

Regards Brian

What exactly do you mean by “invisible”? That the player can’t interact with it at all or that it’s just not mentioned in the room description?

For the former it’s easiest to just not have the item in the room at all and move it there only when it should become visible. For the latter you can make it scenery (3.8. in the manual) or if it’s something that the player should be able to pick up, see for example

The easiest solution is probably to have the object initially out of play, and only move it to the room when it’s made visible. That way, there’s no chance of the player being able to interact with the object at the wrong time.

If you really want the object to be present but invisible, you could try adapting example 345: Low Light from the Inform manual. However, note that the example isn’t quite perfect: you can still take the shadow with “take all” even when it’s invisible. It’s possible to fix that, but it’s not trivial; one would expect the following to do it:

Rule for deciding whether all includes the shadow when the light level is low: it does not.

and, for the example as given, it does. However, it turns out that if the shadow is the only thing in the room, then “take all” still takes it (this may be a bug in Inform):

The following rules seem to work around it, but I can’t be sure that I’ve really plugged all possible holes there might be:

Rule for clarifying the parser's choice of the shadow when the light level is low:	
	issue miscellaneous library message number 44; ["There are none at all available!"]
	say command clarification break.

Check taking the shadow when the light level is low: stop the action.

Thanks for your replies.

One use of making a object invisible is to have the invisible object sitting on top of something called Z but still not seen by the player so if the picks up the Z object then the invisible object is also picked up and where ever the player walks to the invisible object gets carried by the player. If the player drops the Z object in a certain location then the invisible object is also put at that location.

If you just want the hidden object to appear in a container (or on a supporter) only after some specific action, regardless of where that container or supporter is, then that’s easy enough to arrange:

"Nothing up my sleeve"

The Backstage is a room. "This is where the performers await their turn on the stage."

Definition: a container is empty if it does not contain anything.

The magician's hat is a wearable container in the backstage. The description of the hat is "A stylish black top hat with a spacious interior[if empty]. It seems to be empty[end if]." Understand "stylish", "black" and "top" as the hat.

Before printing the name of the empty hat: omit contents in listing.

There is a white rabbit. The description is "A cute fluffy white rabbit." Understand "cute" and "fluffy" as the rabbit.

Instead of searching the empty hat when the rabbit is off-stage:
	say "As you search the black silk lining of the hat, your hand brushes against something warm and fuzzy.";
	now the rabbit is in the hat.

Test me with "x hat / get rabbit / search hat / x hat / l / get rabbit". 

You could even modify that to make the object appear in the room rather than in the container:

Instead of searching the empty hat when the rabbit is off-stage:
	say "As you search the black silk lining of the hat, a fluffy white rabbit suddenly jumps out of it.";
	now the rabbit is in the location of the hat.

(and of course you can make the appearance trigger on any action you want).

All this is assuming that you don’t want the player to be able to interact with the hidden object before it’s revealed. If you do want that, it might be easiest to just make the object “undescribed” (or possibly “scenery”, if you don’t want the player picking it up). A potential problem with undescribed things is that Inform helpfully makes them described if they’re picked up; if we want them to stay undescribed after being moved, we need to re-set the property after the player drops them:

"Light red"

The Metaphysical Realm is a room. "The place where ideas, even paradoxical ones, can take physical form."

The marble pedestal is an enterable fixed in place supporter in the metaphysical realm. The description is "It's big enough that it could easily support a horse. Or perhaps a unicorn."

The Invisible Pink Unicorn is on the pedestal. The description is "You can't see it, but there's definitely a unicorn [on-in the holder of the unicorn]. And it's pink." The unicorn is undescribed.

To say on-in (the holder - an object):
	if the holder holds the player:
		say "here";
	else if the holder is a supporter:
		say "on [the holder]";
		say "in [the holder]".

Report taking the unicorn: say "Somehow, you pick up the invisible pink unicorn." instead.

After doing something with the unicorn when the unicorn is described and the unicorn is not held: now the unicorn is undescribed; say "As you release your hold on the invisible pink unicorn, it seems to vanish as if it had never been there." instead.

Test one with "look / x pedestal / x unicorn / get on pedestal / x unicorn / look / get off".

Test two with "get unicorn / i / drop unicorn / look / get unicorn / put unicorn on pedestal / look / x pedestal".

Thanks vyznev.
They are good examples to refer to.

I still don’t know why inform7 does not have an invisible property for objects. Maybe there will be in a future update.

You can fix that with this.

Rule for deciding whether all includes the shadow: it does not.