Concealing a thing

I have a thin key that I try to conceal beneath a desk blotter. Although the underneath relation works, the thin key is displayed to the player as on the desk. The example below shows a simple case, which also doesn’t work for the general case that I am trying to write. Can anyone help?

[Introduce the UNDERNEATH relation for concealment.]
Underneath relates various things to various things.
The verb to be underneath means the underneath relation.

The thin key is a key. The thin key unlocks the top drawer.
Description of thin key is "A thin long key, easily hidden.".
The thin key is on Robert's desk.
The thin key is underneath the blue blotter.
The thin key is concealed. 

Before taking thin key:
	if thin key is concealed:
		say "DEBUG: concealed[line break]";
		say "You don't see that here." instead;
	otherwise:
		say "DEBUG: exposed[line break]";

The DEBUG statements prints ALWAYS as the key is exposed, but the SHOWME THIN KEY shows that it has the property of concealed. Therefore, TAKE THIN KEY always takes the key, even when it is suppose to be concealed.
Should I move it out of scope?

Hmm, when I try to compile your example, then I first get an error about ‘The thin key is a key’ (“appears to say two things are the same”).

After fixing that by deleting The thin key is a key., the next error is:

Problem. In the sentence ‘The thin key is concealed’, you ask me to arrange for something to be ‘concealed’ at the start of play. […] Like ‘visible’, being ‘concealed’ is something I can test during play at any time, but not something I can arrange at the start.

So, I don’t think you can use “concealed” in that way.

My suggestion would be to leave the key out of play (just declare it, but don’t give it a particular place) until it is discovered.

The examples “Beachfront” and “Beneath the Surface”, both in section §6.6 “Looking Under and Hiding” in the Recipe Book, show some ways to do that.

“Beneath the Surface” also has a similar “underlying” relation, which we could use like this:

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:
	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.

[Additionally, one will probably want to make it so that taking the blotter will also reveal the key, which could be done along the lines of this:]

Last report taking a thing which is underlaid by something:
	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.

[Leaving out the "hiding it under" action for this example here; see recipe book.]

The Study is a room.

Robert's desk is a supporter in the study.

The blue blotter is on Robert's desk.

The top drawer is part of Robert's desk. The top drawer is an openable, locked container.

The thin key unlocks the top drawer.
The description of the thin key is "A thin long key, easily hidden.".

The thin key is beneath the blue blotter.

Hmm, yes. There was some code where key was defined as a kind. I inadvertently omitted those couple lines of code.
I liked the idea of out/in of play. I tried that first then thought concealed/exposed was more general.
Thanks.

OK, I can hide a thin key under a blotter with a PUT IT UNDER action. How do I deal with things that are not keys or blotters. I can check that the player does not try to hide anything under something fixed in place, but what about PUT BACKPACK UNDER QUILL. That won’t hide the backpack. Size seems to be a critical factor for concealing. There seems to be no end to SOMETHING that can be put under SOMETHING. How do I check for that?

You could try giving things a size and then comparing the size in a Check rule, so that the player can’t hide thing A under thing B if B is smaller than A.

We could add the following to the code above (plus the “Hiding it under” action from the example “Beneath the Surface”):

A thing has a number called size. The size of a thing is usually 10.

[...]

Check hiding it under:
	if the size of the second noun is less than the size of the noun:
		say "That's too small to hide [the noun]." instead;

[...]

The pencil is on Robert's Desk. The size of the pencil is 1.

The broom is in the Study. The size of the broom is 20.

Then the output will look like this:

Study
You can see Robert’s desk (on which are a blue blotter and a pencil) and a broom here.

>hide pencil under desk
(first taking the pencil)
You shove the pencil out of sight beneath Robert’s desk.

>hide broom under desk
(first taking the broom)
That’s too small to hide the broom.

(However, it can be difficult to model this in a realistic and general way.)

Is it important that the player is able to hide things under other things?

I hide a key under a desk blotter. The player has an incentive to re-hide the key after pilfering the top drawer of the desk so that owner doesn’t know it’s gone right away. However, if player can enter PUT (something) UNDER (something), I think the player will try to place almost anything under almost any other thing.
I could allow PUT KEY UNDER BLOTTER as the only command; any other attempt will respond “I don’t understand that command.” Perhaps that’s alright.

That particular message seems misleading, as it suggests that the game doesn’t recognise the action anywhere at all.

I’d use a different wording for the general refusal, maybe “You don’t need to hide that there.” or something similar. (While this could motivate the player to try it out fruitlessly in lots of other places, which can be annoying, it does at least avoid the impression that it never works.)