Instead of taking inventory in the dark

I’m using some dark rooms in the Inform 7 game I’m working on, and I would like to prevent the player from checking their inventory in a dark room. I’ve tried things like:

Instead of taking inventory in the dark: say “Not now.”
Instead of taking inventory when the player is in the dark: say “Not now.”
Instead of taking inventory when the location is dark: say “Not now.”
Instead of taking inventory when the player is in a location that is dark: say “Not now.”

Everything I’ve tried uses the Instead exception regardless of whether the player is in a dark room or a lit room. (That is, I always see “Not now.”) I’ve gotten other commands and even this command to accept other exceptions but ‘in the dark’ is causing problems. Does anyone have a suggestion? I’m still learning so I’d love a pointer to the docs that explains why this occurs.

I believe what you want is “when in darkness”. Inform is demanding about its phrasing sometimes. The second two check whether the location would be dark in isolation, with no objects around. In other words, whether the room is inherently dark. If the player has a lit lamp, it’ll still evaluate true. (I’m curious why the first two compile, though…)

Thank you! I must have missed seeing that phrase in the examples I looked at. I guess since I saw ‘in the dark’ used as a condition for rules, I thought it would work in some combination.

Should an Instead line always be followed by ‘when’ in cases like this?

Instead of taking inventory in the dark: say "Not now."
Instead of taking inventory when the player is in the dark: say "Not now."
Instead of taking inventory when the location is dark: say "Not now."

All three of these compile to equivalent code. (Not quite equivalent, but the differences aren’t interesting.) “In X” is being parsed as short for “the player is in an X room”.

[quote]
Should an Instead line always be followed by ‘when’ in cases like this?

[quote]
There are lots of possible cases. :slight_smile: “…in darkness” is a special case which is not equivalent to “…the player is in a dark room”, that the important point here.

Much appreciated, both of you.