Discovery in dark rooms.

I have yet another conundrum.

In my current(ly being developed) game, my player is venturing into a cave in which he hopes to find his beloved being held. This cave has two rooms–the first, at the entrance, which is lit by light coming in profusely from the outside, and the second, which is further in and dark, accessed by a partially hidden passage. What I want to happen here is–
1 if the player enters this room with a light source turned on, he will discover that his girlfriend is not there, with an appropriate response, or
2 if the he enters the room, and only then turns on the light source, he then discovers her still missing, with appropriate response.

In other words, I don’t want the player to ‘discover her missing’ when he can’t see anything. And I want this ‘discovery’ to happen only once, the first time the player sees this room with a light source turned on.
At first glance, this seemed like an easy situation to set up, but I tried numerous things, and none of them worked.

One thing I have not tried yet–if I tack this phrase onto the end of the room description–

[line break][first time]To your utter dismay and disappointment, you find that she is not here, either![only]

Will this phrase print only the first time the player can get a full description of the room, or will it still print like this–
‘It’s dark in here, and you can’t see a thing.
To your utter dismay and disappointment, you find that she is not here, either!’…??


I tried that phrase, using the ‘[first time]…[only]’ substitution and it worked. It printed only the first time when the player can get a full room description, ie, the first time he can see the room with a light source turned on.
Okay, next question-- how can I limit the player’s movement in dark areas(=more than one room, adjacent, and dark) without causing trouble if he has a turned-on light source? I notice, by default, Inform does not prohibit the player from moving between dark rooms, even if the player has no light. What if I want to be able to say ‘You balk at moving any further into the darkness.’…?? I have tried a number of things, but problems resulted when I had the light source on–it would print that phrase regardless. Would the following work?

Check going in a dark room:
if in darkness:
say “Given your fear of the dark, you balk at moving any further.”


For your first problem, try an “after looking when the location is [wherever] and not in darkness for the first time” rule.

For your second one, you’ll need a way to determine whether the destination contains a light source, which isn’t trivial. I have an extension somewhere which defines an adjective for that, so you can make an “Instead of going when in darkness and the destination is not light-filled” rule.

I think this should work.

Before going when in darkness:
	if the room gone to is not nothing and the room gone to is also dark:
		say "You'd rather not go any further in the dark." instead.
To decide whether (R -  a room) is also dark:
	let L be the location;
	let c be false;
	move the player to R, without printing a room description;
	if in darkness: 
		now c is true;
	move the player to L, without printing a room description;
	decide on c.

I tried dropping this into the documentation example “Unblinking” in place of the light-filled routine there but it wouldn’t compile. It looks like it really wants something in parentheses, because when I changed it to this:

Definition: a room is light-filled if I6 routine "OffersLight" says so (hurdy gurdy).

it did compile.

Yes, your I6 sorcery is much better.

I think a solution to that problem would be to make L be “the holder of the player” rather than “the location”–then that should put the player back exactly where they were.

Thanks, guys, for the suggestions. I have overlooked something–the first room in the cave has a huge opening–so it’s not dark during the day(and I don’t want to change this because this same cave features in my first game). It’s the second room that is really dark. But I will keep your solutions in mind, because I am considering possible obstacles that include dark rooms. Thanks!