I am trying to write a darkness rule and having trouble

The game I am creating takes place at night at a dark house. Therefore most all rooms are dark. I want that to be the case until the player gets the flashlight near the start of the game. I read this page. http://inform7.com/book/WI_12_19.html and am trying to apply that. I have tried typing it in various ways to tell the game that as long as the player has the flashlight they can see in dark rooms.

This is what I have right but I have tried several different ways. It either gives me an error when I try to run it, I run it but even with the flashlight rooms are still dark or it gives me an error saying it’s the programs fault. I need a way around this.

Visibility rule when in darkness:
if the flashlight is carried by the player:
there is sufficient light;
there is sufficient light.

Fixed it! I rummaged through the rules and made the flashlight a “lit” object.

2 Likes

Why do you repeat the line there is sufficient light?

I tried it various ways including with out repeating. Nothing worked.

Visibility rules affect whether you can interact with specific objects (so that you can allow things like reading dimly glowing runes on a carried amulet that don’t illuminate the rest of the room) – the room description itself doesn’t care about visibility rules. This is covered in §12.19. Changing visibility.

As FriendOfFred pointed out, in the rule you posted above the condition is useless because the rule will always decide that there is sufficient light.

As you found, the correct way to have the whole room visible is to either declare the room itself to be lighted (although that’s the default, so you actually just need to refrain from declaring it as dark), or to declare that some carried object is lit. This could either be permanent or it could be a temporary state, as in a lantern that is switched on or off, or a torch that has to be set on fire first or that can go out after a certain number of turns. That’s covered in §3.15. Light and darkness. (You could even declare that the player themselves are lit, although that should usually be reserved for something like a magic spell effect that will fade out.)