Suppose we have our player, a detective, searching for evidence; we don't want him to be able to use this evidence until he has performed the action that reveals it, but after that it should be visible in the room when he looks.
A simple way to do this is to start the object -- an envelope, in this scenario -- out of play, and only move it into the location when the player looks for it:
"Beachfront"
The Stuffy Office is a room. "The windows are closed, making the sultry air even more unbearable. A narrow slice of Caribbean blue is visible between the scuba gear rental shop and the recreated 17th century pirate tavern.
The office is cheerfully furnished with wicker chairs and white curtains, but the tropical decorating scheme stopped at the desk, which is heavy oak and absolutely covered with papers."
The heavy oak desk is a supporter in the stuffy office. It is scenery. Understand "paperwork" as the desk.
The creamy envelope is an openable container. The description is "There is no return address on the outside of the envelope, just the address of the Doctor's office -- but the legs of the capital A are rubbed down in a characteristic way, and the top of every R is open. There's no question that it comes from the same typewriter as the blackmail note." In the envelope is a letter. The envelope can be found or lost. The envelope is lost.
Instead of searching the desk when the envelope is lost:
now the envelope is found;
say "You rifle through the piles of bills and notices; invitations to conventions; advertisements for high-end prescription drugs; pink carbon sheets bearing patients['] names and medical identification numbers in spidery, elderly handwriting. Almost at the bottom of the heap, you find what you were looking for: a creamy envelope with the address typed.";
move the envelope to the desk.
Here we've changed the property of the envelope to keep track of the fact that it has been found, so that if the player tries again, he won't find anything more.
Instead of searching the desk:
say "Further investigation of the desk reveals nothing else suspicious."
Notice that we have two rules that apply to "searching the desk", but one of them has a more specific set of parameters ("when the envelope is lost"). This means that Inform will consult that rule first and use it if it applies; it will only carry out our plain vanilla "instead of searching the desk" rule when the more restricted rule is not relevant.
Test me with "x envelope / x desk / search desk / look / get envelope / x envelope".
"Matreshka"
Ransacking is an action applying to one thing.
Check ransacking:
if the noun is not the location, say "You can hardly search [the noun] from here." instead.
Carry out ransacking:
while the player can see a closed openable unlocked container (called target):
say "[target]: [run paragraph on]";
try opening the target.
Report ransacking:
say "You can see nothing further worth searching."
The Russian Gift Shop is a room. In the Russian Gift Shop is a large wooden doll. It is closed and openable. In the large wooden doll is a medium wooden doll. It is closed and openable. In the medium wooden doll is a small wooden doll. It is closed and openable. In the small wooden doll is a tiny solid wooden doll.
And now we need to borrow from a later chapter for the command that will make this work:
Understand "search [any visited room]" as ransacking.
Test me with "search gift shop".
"Flashlight"
The Schoolhouse is a room. "Though normally comfortable, the room is dark and menacing during the storm; rain sheets on the windows, and you can barely see the flash of the lighthouse only a few miles away."
The cabinet is a fixed in place openable container in the Schoolhouse. The hurricane lantern is a thing in the Schoolhouse. "A hurricane lantern hangs from a peg." The lantern is lit.
Visibility rule when looking under something:
if the player is carrying a lit thing (called lamp):
say "You shine [the lamp] under [the noun]...";
there is sufficient light;
there is insufficient light.
There is a marble. The marble can be found or lost. The marble is lost.
Instead of looking under the cabinet when the marble is lost:
move the marble to the player;
now the marble is found;
say "Billy's lost marble! So that's where it got to!"
Test me with "look under cabinet / get lantern / look under cabinet".
Because visibility is checked before instead rules, this discovery will (correctly) occur only when the player does have enough light.
The standard world model provides for the idea of containers and supporters, but this is not the only way that objects can relate to one another in the real world. Here we try adding the idea of concealment beneath another object:
"Beneath the Surface"
Section 1 - In Which our Terms are Defined
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.
Hiding it under is an action applying to one carried thing and one thing. Understand "put [something preferably held] under [something]" as hiding it under. Understand "hide [something preferably held] under [something]" as hiding it under. Understand the commands "shove" and "conceal" and "stick" as "hide".
Check hiding it under:
if the second noun is not fixed in place, say "[The second noun] wouldn't be a very effective place of concealment." instead.
Carry out hiding it under:
now the noun is nowhere;
now the noun underlies the second noun.
Report hiding it under:
say "You shove [the noun] out of sight beneath [the second noun]."
Section 2 - In Which They are Put To Use
The Room of Hidden Objects is a room. It contains a sofa, an easy chair, and a rug. The sofa supports a lime-green pillow and an innocent-looking Chinese finger toy. The rug is fixed in place. The chair is a supporter.
A treasure map underlies the easy chair. A skeleton is beneath the sofa. A blueprint of Atlantis, a lexicon of Linear A, and the key to Jimmy Hoffa's Mausoleum are under the rug.
Test me with "look under the sofa / look under the rug / look under the easy chair / hide lexicon under rug".