3.7. Lighting

| Chapter 3: Place |

| 3.7. Lighting

At any place (room, or inside a container) light is either fully present or fully absent. Inform does not usually try to track intermediate states of lighting, but see The Undertomb 2 for a single lantern with varying light levels and Zorn of Zorna for multiple candles that can be lit for cumulative changes to the light level.

Light can be added to, but not taken away: rooms and things can act as sources of light, by having the "lighted" and "lit" properties respectively, but they cannot be sinks which drain light away. The reason darkness is not a constant hazard in Inform-written games is that rooms always have the "lighted" property unless declared "dark". (We assume daylight or some always-on electric lighting.) A "dark" room may well still be illuminated if a light source happens to be present:

> The Deep Crypt is a dark room. The candle lantern is a lit thing in the Deep Crypt.

Hymenaeus allows us to explicitly refer to torches as "lit" or "unlit", or (as synonyms) "flaming" or "extinguished".

For light produced electrically we might want a wall switch, as in Down Below, or a portable lamp, as in The Dark Ages Revisited.

The fierce, locally confined light thrown out by a carried lamp has a quality quite unlike weak but ambient daylight, and Reflections exploits this to make a lantern feel more realistic.

When the player experiences darkness in a location, Inform is usually very guarded in what it reveals. ("It is pitch dark, and you can't see a thing.") Hohmann Transfer gives darkness a quite different look, and Four Stars heightens the other senses so that a player in darkness can still detect her surroundings. The first of the two examples in Peeled allows exploration of a dark place by touch.

It is sometimes useful to check whether a room that is not the current location happens to contain a light source or be naturally lighted. This poses a few challenges. Unblinking demonstrates one way of doing this, so long as there are no backdrop light sources.

Cloak of Darkness is a short and sweet game based on a light puzzle.

See Room Descriptions for an item that can only be seen in bright light, when an extra lamp is switched on

See Looking Under and Hiding for a looking under action which is helped by the fiercer brightness of a light source

See Going, Pushing Things in Directions for making it hazardous to walk around in the dark

See Electricity and Magnetism for batteries to power a torch or flashlight

See Fire for a non-electrical way to produce light

49
| Example The Undertomb 2 Flickering lantern-light effects added to the Undertomb. |
WI

333
| Example Zorn of Zorna Light levels vary depending on the number of candles the player has lit, and this determines whether or not he is able to examine detailed objects successfully. |
WI

301
| Example Hymenaeus Understanding "flaming torch" and "extinguished torch" to refer to torches when lit and unlit. |
WI

25
| Example Down Below A light switch which makes the room it is in dark or light. |
WI

Suppose we want to have a room with a light switch. Turning the switch off makes the room go dark; turning it on restores the light. This kind of switch is an obvious candidate as a device. "Down Below" Terrifying Basement is a room. The light switch is a switched on device in the Terrifying Basement. It is fixed in place. Here we define our light switch, and we also make it start out as "switched on". The Terrifying Basement will also start out lit (as all rooms do, by default, unless we specifically say that they are dark). We further say that it is fixed in place to avoid the ludicrous possibility of the player picking it up and carrying it away. Next we add some instructions to control how turning the light switch on and off affects the room light. These borrow from later chapters on actions, but the gist may be obvious anyway: Carry out switching off the light switch: now the Terrifying Basement is dark. Carry out switching on the light switch: now the Terrifying Basement is lighted. Inform already has the idea of light and darkness built in; we will see more about this later, and the Phrasebook (in the Index tab) also contains a list of all the adjectives (lighted, dark, etc) which are important to use here. Speaking of the Index, the Actions tab contains a list of all the grammar that can be used to activate a given command: for instance, the switching action responds to "switch [something]" or "turn on [something]". In this case, we may want to give the player an extra option or two. It would be pretty natural for a player to try >FLIP SWITCH, so let's add that in: Understand "flip [something switched off]" as switching on. Understand "flip [something switched on]" as switching off. Understand "flip [something]" as switching on. The nuances of this will be explored in the chapter on Understanding. What is useful to know here is that we have taught Inform to understand that >FLIP LIGHT SWITCH means to turn it on when the switch is already off; if the switch is already on, FLIP SWITCH means to turn the switch off. Depending on the kind of device we are modeling (button? lever? dial?), we might want to write similar lines for commands such as PUSH, PRESS, PULL, TURN, and so on. Finally, we need to deal with a special case. In general, the player cannot interact with other things in a dark room because he can't see them, but if we adhered strictly to this it would be impossible for him to find the light switch to turn it back on. So we need something from the chapter on Activities to change this: After deciding the scope of the player when the location is the Terrifying Basement: place the light switch in scope. Upstairs is above the Terrifying Basement. Test me with "turn off light / look / flip light switch".

194
| Example The Dark Ages Revisited An electric light kind of device which becomes lit when switched on and dark when switched off. |
WI

338
| Example Reflections Emphasizing the reflective quality of shiny objects whenever they are described in the presence of the torch. |
WI

334
| Example Hohmann Transfer Changing the way dark rooms are described to avoid the standard Inform phrasing. |
WI

335
| Example Four Stars An elaboration of the idea that when light is absent, the player should be given a description of what he can smell and hear, instead. |
WI

350
| Example Peeled Two different approaches to adjusting what the player can interact with, compared. |
WI

81
| Example Unblinking Finding a best route through light-filled rooms only, leaving aside any that might be dark. |
WI

280
| Example Cloak of Darkness Implementation of "Cloak of Darkness", a simple example game that for years has been used to demonstrate the features of IF languages. |
WI

Previous | Contents | Next