Making an object invisible

This one has a few steps.

Definition: A thing is invisible if it cannot be seen by the player. Definition: A thing is visible if it can be seen by the player.
Underlying relates various things to one thing. The verb to underlie means the underlying relation. The verb to be under means the underlying relation. The verb to be beneath means the underlying relation.

Instead of looking under a thing which is underlaid by something (called the lost object):
	say "You find [the list of things which underlie the noun]!";
	now every thing which underlies the noun is carried by the player;
	now every thing which underlies the noun does not underlie the noun.
	
Some papers are in the Salon. The bronze key is under the papers. The bronze key unlocks the bronze locked door. The bronze key is invisible. After looking under the papers: The bronze key is visible.

Error:

In the sentence ‘A thing is invisible if it cannot be seen by the player’ , you ask me to arrange for something to be ‘invisible’ at the start of play. There are some adjectives (‘open’ or ‘dark’, for instance) which I can fix, but others are just too vague. For example, saying ‘Peter is visible.’ isn’t allowed, because it doesn’t tell me where Peter is. Like ‘visible’, being ‘invisible’ is something I can test during play at any time, but not something I can arrange at the start.

So I get that. But that’s exactly why I defined it, though?

1 Like

So I realized I forgot to add that the key is a lost object, but now it says that a thing cannot be two things at once.

I suspect the issue is that you’re trying to manually set the visibility/invisibility of an object, but you’ve told Inform those are calculated values - like “the bronze key is visible/invisible” doesn’t make sense as a thing to directly set, since that’s a consequence of where it is and where the player is.

The typical way to deal with this kind of stuff is to just keep the relevant object off-screen, and then use something like your after rule to move it into the location (or you could have it in place but not described, and/or use an instead rule to intercept attempts to interact with it before it’s been “found”). And since you can just directly ask Inform whether the player can see an object, the definitions approach might also be over complicating things. But FWIW this code works the way you’d think it should:

Laboratory is a room. the papers are in laboratory.  the closet is east of laboratory.

Definition: A thing is invisible if it cannot be seen by the player.

Definition: A thing is visible if it can be seen by the player.

every turn:
	if the papers are visible, say "visible.";
	if the papers are invisible, say "invisible."

Have you defined “lost object” as a kind of thing elsewhere in your code? If not, that’s probably why you’re getting the second error.

1 Like

Oh yeah. I guess I was trying to punch above my weight on this one. I put everything inside brackets and just added a simple after rule and now it works.

1 Like

If it’s a helpful data point, relations are right there with doors on the list of things that intimidate me and that I’ve never really used :slight_smile:

2 Likes

On the upside, trying more ambitious things is good! I think I’m starting to become comfortable with consulting the documentation.

1 Like

Relations are one of the most inspired aspects of Inform! Take the plunge!

3 Likes

The key is, a definition like that is underspecified. You’re telling Inform that something is invisible if it can’t be seen by the player. But there are all sorts of reasons why something can’t be seen by the player—it could be in another room, it could be in a locked container, it could be in the dark, it could be off-stage completely. So when you tell Inform to make something invisible, well…which of those should it be?

3 Likes