Darkness inside a container

This should be easy, but: How do you make it dark inside a container?

If the container is enterable, closed, and opaque it should be dark by default.

What if it’s not openable?

Hrmp. Someone probably knows better than I do, but I might try just surreptitiously closing and opening the container as you enter and exit:

The Bedroom is a room. The underside of the bed is a container in the Bedroom. The underside is enterable. After entering the underside: now the underside is closed. Before exiting from the underside: now the underside is open. Report exiting from the underside (this is the don't describe the darkness rule): rule succeeds. The don't describe the darkness rule is listed after the standard report exiting rule in the report exiting rulebook.

The don’t describe the darkness rule was necessary because the describe room emerged into rule was printing a description of darkness before the description of the Bedroom printed. I think that it may not have recalculated the lighting situation at the right time – it thought it was still dark when it was time to report exiting, so it printed the description of a dark room, and then it recalculated that it was light, so it tried looking (does that usually happen when the lights go on?) Anyway, this seems to work for now, though it’s obviously hacky.

Huh. I’ve run into a strange issue: This code continues to report darkness even after you open the container and get out.

[code]The house is a room.

The box is an enterable, opaque container. It is closed and openable. It is in the house.

Mary is a woman. She is in the box. The player is Mary.[/code]

Indeed. This looks like a big bug in Inform 7 to me.

Yup, that’s what led me to include the don’t describe the darkness rule. (Which has the effect of suppressing the describe room emerged into rule when exiting the underside of the bed.) I’ve reported it.

I tracked it down to the following lines in the Position Player In Model World Rule:

if (player_to_be ~= player) { remove selfobj; ChangePlayer(player_to_be); } real_location = location; SilentlyConsiderLight();
The ChangePlayer routine correctly sets location and real_location to thedark and the house respectively. But then the next line sets real_location from location, so now it too is thedark (which it should never be).

In the meantime you can fix it like this:

[code]The house is a room.
The box is a closed, openable, enterable, opaque container in the house.
Mary is a woman in the box. The player is Mary.

Include (-
[ POSITION_PLAYER_IN_MODEL_R player_to_be;

player = selfobj;
player_to_be = InitialSituation–>PLAYER_OBJECT_INIS;

location = LocationOf(player_to_be);
if (location == 0) {
location = InitialSituation–>START_ROOM_INIS;
if (InitialSituation–>START_OBJECT_INIS)
move player_to_be to InitialSituation–>START_OBJECT_INIS;
else move player_to_be to location;
}

if (player_to_be ~= player) { remove selfobj; ChangePlayer(player_to_be); }
else { real_location = location; SilentlyConsiderLight(); }

NOTE_OBJECT_ACQUISITIONS_R(); MoveFloatingObjects();

actor = player; act_requester = nothing; actors_location = real_location; action = ##Wait;

InitialSituation–>DONE_INIS = true;
rfalse;
];
-) instead of “Position Player In Model World Rule” in “OrderOfPlay.i6t”.[/code]

Matt, this seems to happen even with your modified rule in play:

[code]The house is a room.

The box is an enterable, opaque container. It is closed and openable. It is in the house.

After entering the box:
now the box is closed;
continue the action.

Before exiting from the box:
now the box is open.

Report exiting from the box (this is the don’t describe the darkness rule): rule succeeds.
The don’t describe the darkness rule is listed after the standard report exiting rule in the report exiting rulebook.

Mary is a woman. The player is Mary. Mary is in the box.
[/code]

Weird. When the player is asserted to start in the box, the game never seems to realize that the house is lighted even when you leave the box. If you replace “Mary is in the box” with “When play begins: Now Mary is in the box,” that doesn’t happen. But “showme house” reveals that the room is lighted.

Sort of seems like a separate bug to me – my rule is preventing the “describe room emerged into” rule from firing, but the looking action is producing a darkness report. (If you delete the “don’t describe the darkness” rule, then exiting the box will produce two reports of darkness!) I don’t have time to report that just now – anyone want to take a whack at it, feel free.

Anyway, this is further proof that my solution is hacky; you should probably try SJ’s.

Three further observations:

  1. You actually have to use both solutions, because Matt’s rule is still needed to suppress the announcement of darkness after you leave the box.

  2. When you get back in the box, because you’re changing it from open to closed after you get in, it tells you “It is now pitch dark in here!”, which is awkward in this case, so you need one additional rule (this is adequate in my case because it’s the only area of darkness in the game):

Rule for printing the announcement of darkness: stop.

  1. Since it’s momentarily light when you get in the container, it lists all the contents of the container–but if you try to do anything with them, it’ll tell you you can’t see any such thing because it’s dark.

All in all, I really wish I could just set enterable containers to always be dark.

Are you sure you want to use the built in darkness? It seems to me that what you want probably can be accomplished in some easier way.

Yeah, you seem to be talking about two unrelated issues. My post was about katz’s Mary Trapped In Darkness Forever bug.

Would this work for you?

[code]The house is a room.
The box is an enterable, opaque, closed, container. It is in the house.
Mary is a woman. She is in the box. The player is Mary.

Instead of entering a container (called the box): move the player to the box.
Instead of exiting from a container (called the box): move the player to the location of the box.

For printing room description details of an enterable container: stop.[/code]

The last rule of course stops all room description details of enterable containers; but if they are always dark, that might not matter to you.
Apparently, the Trapped In Darkness Forever bug is circumvented by moving Mary out of darkness by force rather than letting her exit by herself.

I see – I hadn’t tested her new code, so I hadn’t yet realized that there were two bugs there (and that your code was addressing the other one). OK, if no one else gets to that one then I’ll file the Darkness Forever bug with a pointer to your solution. Eventually.

UPDATE: Reported.

Yeah, I’m thinking it would be easier to just suppress the description of the outside when in the container; that’s the most important concern for me.

Why not make it a room? That is, you could implement the container as a container, but whenever the player enters it you could send her to a room. (Ditto when she puts something in it.) If you look around for the Foxaroo TARDIS thread there’s some discussion of that.

Thanks!