More on hidden objects?

In my world, there is a trap door at the bottom of a cell. Is there a relatively simple way of making it so that I cannot interact with the trap door until I move the pile of straw? (Exactly like the situation in Zork 1 with the grating under the leaves in the forest). I would prefer one that is simple for a noob like me.

Something like this, perhaps.

Before doing something with the trap door when the pile of straw is in the cell:
    say "You can't see any such thing." instead.

This is not an optimal solution, as the trap door will still be listed in disambiguation lists and such. But it should prevent the player from interacting with it directly.

Piggy-backing on that, I thought of something along these lines: (untested)

[code]a thing can be hidden or not hidden. a thing is usually not hidden.

the trapdoor is hidden.

instead of doing something with the trapdoor:
if the trapdoor is hidden:
say “You can’t see any such thing.”;
continue the action.

instead of searching the pile of straw for the first time:
now the trapdoor is not hidden;
continue the action.

If you really want to conceal the trapdoor so that the player cannot interact with it in any way, you could include Scopability by Brady Garvin and make the trapdoor “unscopable” until the player searches the straw.

@MTW: You can also restrict the property just to that one object by saying “the trapdoor can be hidden or not hidden”.

MTW: Your solution brings up the following message: “Problem. You wrote ‘say “You can’t see such a thing.” otherwise’ : but the punctuation here ‘:’ makes me think this should be a definition of a phrase and it doesn’t begin as it should, with either ‘To’ (e.g. ‘To flood the riverplain:’), ‘Definition:’, a name for a rule (e.g. ‘This is the devilishly cunning rule:’), ‘At’ plus a time (e.g. ‘At 11:12 PM:’ or ‘At the time when the clock chimes’) or the name of a rulebook, possibly followed by some description of the action or value to apply to (e.g. ‘Instead of taking something:’ or ‘Every turn:’).” Did I type somethign wrong?

Well, it’s not tested. Not sure what’s up. Judge Judy is on, I will check later.

I suggest doing this with “privately-named” and “Understand when…”, like this:

[code]The Lab is a room.

A trapdoor is a privately-named, scenery thing in the Lab. A trapdoor can be revealed or not revealed. A trapdoor is not revealed. Understand “trap”, “door”, and “trapdoor” as the trapdoor when the trapdoor is revealed.

A pile of straw is a thing in the Lab.

Instead of searching the pile of straw when the trapdoor is not revealed:
say “My goodness, there was a trapdoor hidden in the straw!”;
now the trapdoor is revealed;
now the trapdoor is not scenery.

I think it’s “instead of doing something to the trapdoor”.

Thank you. Haven’t coded in a few weeks now. :slight_smile:

Either “to” or “with” works, actually.

Lizard, I think the problem you got is that you left out the semicolon after ‘say “You can’t see any such thing.”’ When that happens Inform thinks that the next line is actually a continuation of that one, and you get one sort of weirdness or another. A way to tell this has happened is often when the error message runs together two lines of your code. (The specific error messages are often not very clear in this case, because Inform is trying to guess what kind of syntax you were trying to put together there, and failing badly.) Put that semicolon in and it should work–at least, MTW’s code worked when I put the semicolon in, did the tab stops, and included a room with the requisite objects in it.

cvaneseltine’s solution is nice, though, and seems more effective. That works because if the trapdoor is privately-named the player can’t use its name to refer to it–and if they have no way to refer to the trapdoor then they can’t interact with it. And as she did it’s important to make the trapdoor “scenery” because otherwise the room description prints “You can see a trapdoor here,” which tends to spoil the effect!

By the way, for most things the traditional way to do this is to just start the object off-stage and move it into the room when it’s revealed. But that’s difficult for doors, because ordinarily you can’t move doors during the course of play. David Corbett (Gorobay on this forum) has an extension Mobile Doors that lets you move doors in play, so you might be able to use that; I think that extension works in version 6L38 of Inform but not 6L02. But all told, it’s probably simpler to use Marshall’s or Carolyn’s solution or Scopability.

Thanks a million all you guys. MTW, yours worked, I did forget the semicolon.

Oh, cool. Def check out cvaneseltine’s code, tho. It will come in handy, I’m sure.

BTW- Judge Judy was a repeat. :frowning:

Actually, it is not too dissimilar from the Inform 7 port of Dungeon (Zork) by Dean Menezes some year’s back in 2006/7 with build 4X60.
The relevant bit of code from the forest is

[code]Clearing has description “This is a clearing, with a forest surrounding you on the west and south.” A pile of leaves is here.

The later appearance of the pile of leaves is “There is a pile of leaves on the ground.”

The size of the leaves is 25.

The grating is a secret door. The grating is down from Clearing and up from Grating Room. The grating is closed, openable, locked, and lockable.

After taking or pushing or pulling the leaves for the first time:

say “Moving the pile of leaves reveals a grating.”;

now the grating is revealed.

Every turn: if the player is in Grating Room, now the grating is revealed.[/code]

That seems to rely on Andrew Owen’s Secret Doors extension; it could probably be updated for the latest Informs pretty easily (you’d have to replace the Inform 6 Library Message inclusions with the new responses) but I don’t think anyone’s done so, partly because there are other workarounds–I think MTW’s patch amounts to a lot of the same thing.

Now I have a problem again. I tried making it so that when you move or examine the hatch, it becomes not hidden. It works fine for examining, but when I move it it says “Nothing obvious happens here.”
This is one of the things I have tried:

Instead of examining or moving pile of straw:
say “You see a hatch beneath the straw.”.

Instead of doing something with the hatch:
if the hatch is hidden:
say “You can’t see such a thing.”;
Continue the action.

Instead of examining or moving the straw for the first time:
now the hatch is not hidden;
continue the action.

Just for the record the Secret Doors extension that matt mentioned works fine - doesn’t need any updates. Similar technique to MTW’s, but uses library messages, and also bars movement.

Include Secret Doors by Andrew Owen.

the Pantry is a room. "The pantry has a filthy floor,[line break]strewn with food and rancid straw.".
the Dungeon is a room.
the trapdoor is a secret door, down from the pantry and up from the dungeon.
the pile of straw is scenery in the pantry.
instead of examining the straw for the first time:
	say "You rummage in the filthy straw.[line break]My god, you find a big trapdoor!";
	now the trapdoor is revealed.


The pantry has a filthy floor
strewn with food and rancid straw.

You can't go that way.

>x trapdoor
You can't see any such thing.

>x straw
You rummage in the filthy straw.
My god, you find a big trapdoor!

>x trapdoor
You see nothing special about the trapdoor.

(first opening the trapdoor)

One caveat with “for the first time” is that failed actions still count. So if the player tries to move the straw, and fails because of some other rule (e.g. perhaps you cannot move, push, or pull objects while wearing oven mitts), that still counts as “the first time” and the trapdoor will not be revealed in the future. You might want to change that to “when the trapdoor is not revealed”.

I tried that too, but moving the straw is still not making the hatch not hidden. I want a solution that does not require any extensions please.

The command “move straw” translates into the action “pushing the straw.” Maybe if you change “moving” to “pushing” it’ll work?

(You may have defined a “moving” action… but unless you tell Inform that “move” doesn’t mean pushing it’ll still parse “move straw” as pushing the straw. Probably better to just use the built-in pushing action.)

That seems to have done the trick. Thanks.