I'm in the dark here

I have a series of dark rooms in a region. According to section 3.15, rooms should become lighted as lit things move into them.

A thing with the property of being "lit" will enable the player to see inside dark rooms, and to carry out other activities requiring light, such as examining items.
However, I have a candlestand that is lit, but when I move into the room. the room stays dark, per the showme command. Shouldn’t LOOK adjust for lit things in the room and change the state to “lighted”?

Similarly, I expect that an originally dark room would go dark again when the lit item is removed from the room.

I can make a list of all lit things that enter the room but would prefer not to do that.
Any idea what is going on here?


My understanding is that “dark” is an inherent property of the room, indicating that you need a light source to see while you’re in it, rather than a state-tracking variable indicating whether there’s currently light in the room or not. So that shouldn’t be changing when you bring a candlestick into a darkened room, since if you leave, drop the candlestick, and come back again, it should still be dark (of course, you could write an appropriate rule to flip the room so it’s no longer dark if the player uses the candlestick to light some sconces, say).


Yep, “dark” means “not offering light”, rather than “not filled with light”. This is so that you can say things like “the Cave is a dark room”, and have Inform understand it; if “dark” meant “not filled with light”, it would complain that it’s not sure how to accomplish your instructions (how can it be sure there’s no light there if the player can move things around?).

If you want an adjective meaning “not filled with light”, try this:

Definition: a room is illuminated rather than darkened if I6 routine "OffersLight" says so (it is lit by itself or contains a light source).

You are likely to be eaten by a Grue.


I don’t understand your answer. Perhaps I should have said “lighted” property, instead of state. I bring a lit candle into a dark room; the room stays dark and I cannot see, despite the lit candle in the room.

Ha! I also used that joke reference in my story.

What I did was count the number of lit things in the room and carried by the player, viz:

After going to room in Crypticon:
	let L be a list of objects;
	add list of lit things in location of player to L;
	add list of lit things carried by player to L;
	carry out counting the number of lit things rule;
	if the number of entries in L is 0:
		now location is dark;
		now location is lighted.	

where Crypticon is a region of several dark rooms.
However, I do this for every room so I want a rule (or activity?) so I don’t have to place that code block everywhere. I tried this, but it didn’t work.

Counting the number of lit things is an activity.
This is the activity-based counting number of lit things rule:
	let L be a list of objects;
	add list of lit things in location of player to L;
	add list of lit things carried by player to L;

(Of course, I don’t have both blocks of code active at once.)

1 Like

You shouldn’t need to manually track that sort of thing. Inform handles all of that automatically, in a way that also handles e.g. a lit thing in an open container, or on a supporter, or being worn.


Can you post a code excerpt that displays this behavior? Out of the box, if you bring lit candle into a dark room you will be able to see, so something’s gone wrong!

(Also, seeing your fairly elaborate code excerpts in the following post, it’s worth asking if you’re trying to do something more complex than the default behavior - like, is the number of lit objects important in some way beyond there just being at least one?)


Yeah, seeing that rule… I think it’s very likely this mechanism is going wrong and setting a room to dark at the wrong time.

What you want in general is, if the room is one where you wouldn’t be able to see without bringing in a light source, set it dark and leave it that way.

The only good reason to set it to lit is if a permanent change occurs making it non-dark. e.g. You pressed a button that opened the ceiling and let the sun in.

If the player holds a light source while they’re in a room that’s set dark, they’ll automatically be able to see.

I don’t know how great Inform is at checking the edge cases on its own. e.g. A corpse in the room holds a box, that’s open, with a light orb inside. If you need to check something like this yourself in code, to see if a player can see Right Now, the extension docs example ‘Unblinking’ uses a trick with a prop it calls a light-meter. It goes like this:

The light-meter is a privately-named scenery thing. 

Definition: a room (called the target room) is light-filled: 
	if the target room is lighted, decide yes;
	move the light-meter to the target room;
	if the light-meter can see a lit thing, decide yes;
	now the light-meter is off-stage;
	decide no;

This means your test can be ‘if the kitchen is light-filled’. This doesn’t check if the kitchen is inherently lit or dark, it checks if a person can see in the kitchen right now, based on both the kitchen’s natural light or darkness, and anything producing light that’s in the kitchen.



What you’re doing here is trying to replicate the built-in logic for whether the player has sufficient light. The built-in logic doesn’t set rooms dark or lighted – it doesn’t have to.

Replicating all that is likely to be frustrating; the built-in logic handles a lot of cases. It’s also unnecessary – you can just check “if in darkness” at any time.


Ok. I removed the L List of lit things. Here is some code, and “if in darkness” produces an error.
Problem. You wrote ‘if in darkness’ : but there doesn’t seem to be any body to this phrase, in the way that a ‘repeat’, ‘if’ or ‘while’ is expected to have.

Problem. You wrote ‘say “The light from the [lit thing] illuminates the room.”’ , but ‘lit thing’ is used in a context where I’d expect to see a (single) specific example of a sayable value, not a description.

After closing stairwell door:
	if in darkness:
		say "As you close the double doors, darkness engulfs you.";
		say "The light from the [lit thing] illuminates the room.";

Regarding the second error: How do I determine (or say) what is lit. The player may have more than one lit thing.

I found the “in the darkness” error. I had another scrap of incomplete code elsewhere with the region using that phrase. I have removed the bad code and cleaned out the complicated rule for finding lit things. Question is then: How can I know what the player is carrying so I can mention it; as in

say "The light from the [lit thing carried by the player] illuminates the room."

Try “[a random lit thing carried by the player]” (note – syntax not tested but I’m pretty sure this is right!) if there’s only one and the choice doesn’t matter; if there are potentially multiple ones and it’s important which gets picked, you probably want to set up a to-say phrase or something like that to prioritize.

1 Like

I would say [the random visible lit thing], which picks something the player can see even if they’re not carrying it, and applies the proper article automatically.

1 Like

I don’t get this reference. could you explain?

In the original Adventure game, the player is warned before proceeding into darkness that “they are likely to be eaten by a grue”. If you proceed, the game is over and you are told that you were eaten by a grue.

In my game, as you look down the dark stairwell, the stairs are described as grue-some.

Thanks. I’m going to try the “random visible thing” because it is possible that the player will drop the candlestand to do stuff and may not have it in hand. I’ll let you know what happens.

Yes, random visible thing worked, but it also produced “nothing” if in the dark.

I have light at the top of the stairs coming from an adjacent room but if the doors are closed, it should be dark at the top of the stairs. I remove the light in the same action as I check for darkness, but it seems to delay darkness.

After closing the stairwell door in Stairwell Upper Level:
	now SC_light is nowhere;
	if in darkness: 
		say "As you close the double doors, darkness engulfs you.";
		say "The light from your [the random visible lit thing] illuminates the room.";

What I get is
“The light from your nothing illuminates the room.”
“It is now pitch dark.”
Is there a way for the After action to wait a tick?