§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


arrow-up.pngStart of Chapter 3: Place
arrow-left.pngBack to §3.6. Windows
arrow-right.pngOnward to §3.8. Sounds

*ExampleThe Dark Ages Revisited
An electric light kind of device which becomes lit when switched on and dark when switched off.

*ExampleHymenaeus
Understanding "flaming torch" and "extinguished torch" to refer to torches when lit and unlit.

*ExampleReflections
Emphasizing the reflective quality of shiny objects whenever they are described in the presence of the torch.

*ExamplePeeled
Two different approaches to adjusting what the player can interact with, compared.

**ExampleDown Below
A light switch which makes the room it is in dark or light.

**ExampleThe Undertomb 2
Flickering lantern-light effects added to the Undertomb.

**ExampleHohmann Transfer
Changing the way dark rooms are described to avoid the standard Inform phrasing.

***ExampleUnblinking
Finding a best route through light-filled rooms only, leaving aside any that might be dark.

***ExampleZorn 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.

paste.png "Four Stars"

A thing has some text called sound. The sound of a thing is usually "silence".

The report listening rule is not listed in the report listening to rules.

Carry out listening to something:
    say "From [the noun] you hear [the sound of the noun]."

Instead of listening to a room:
    if an audible thing can be touched by the player, say "You hear [the list of audible things which can be touched by the player].";
    otherwise say "A merciful peace prevails."

Definition: a thing is audible if the sound of it is not "silence".

Before printing the name of something audible while listening to a room:
    say "[sound] from the "

A thing has some text called scent. The scent of a thing is usually "nothing".

The report smelling rule is not listed in the report smelling rulebook.

Carry out smelling something:
    say "From [the noun] you smell [scent of the noun]."

Instead of smelling a room:
    if a scented thing can be touched by the player, say "You smell [the list of scented things which can be touched by the player].";
    otherwise say "The place is blissfully odorless."

Definition: a thing is scented if the scent of it is not "nothing".

Before printing the name of something scented while smelling a room: say "[scent] from the "

The Waning Moon Resort is a dark room. "A spacious room with a flagstone floor, and a dreamcatcher hung over the king-size bed." The dreamcatcher is scenery in the Resort. The description is "The usual web of threads and crystals, feathers and beads." Instead of taking the dreamcatcher, say "Ah, ah -- you might be tempted to take it as a souvenir, except that the price list in the minibar clearly states they charge $65 apiece if you walk off with one. Cheaper than stealing the Frette bathrobes, but still probably not a good idea."

The king-size bed is an enterable supporter in the Resort. The description is "200-thread-count Egyptian cotton sheets, according to the website. You would make fun, only they really are extraordinarily comfortable." The player is on the bed. A Lindt chocolate is on the bed. It is edible. The scent of the chocolate is "chocolate-hazelnut smell".

Instead of exiting: say "You are too weary to move."

The suitcase is an openable closed container in the Resort.

An electric light is a kind of device. Carry out switching on an electric light: now the noun is lit. Carry out switching off an electric light: now the noun is unlit. Understand "light" as an electric light.

The solar lamp is an electric light in Waning Moon Resort. The description is "Specially designed to give light in a spectrum resembling sunlight, to improve the mood and make a person energetic." The lamp is switched on and lit.

An electric noisemaker is a kind of device. An electric noisemaker has some text called usual sound. The usual sound of an electric noisemaker is usually "beepbeepbeep". Carry out switching on an electric noisemaker: now the sound of the noun is the usual sound of the noun. Report switching on an electric noisemaker: say "[The noun] goes [usual sound of the noun]!" instead. Report switching off an electric noisemaker: say "You switch off [the noun], silencing the [usual sound of the noun]." instead.

Carry out switching off an electric noisemaker: now the sound of the noun is "silence".

The bedside table is in the Resort. The table supports a potted plant and a Bose speaker. The scent of the potted plant is "rosemary"

The Bose speaker is an electric noisemaker. The usual sound of the speaker is "soothing whalesong". The sound of the speaker is "soothing whalesong". The speaker is switched on.

Instead of touching a device: say "You feel the surface of [the noun] and discover the switch."

Instead of touching a scented thing: say "The brush of your fingers stirs loose a fresh cloud of [scent of the noun] smell."

Rule for printing the description of a dark room: try listening; try smelling; rule succeeds.

Instead of examining an audible thing while in darkness: try listening to the noun. Instead of examining something while in darkness: try touching the noun.

Before touching something when in darkness:
    say "You grope about..."

After inserting the plant into something:
    say "You unceremoniously dump [the noun] into [the second noun], hoping it sustains no important damage thereby."

Before printing the name of a dark room: if the player can touch an audible thing, say "Noisy "; if the player can touch a scented thing, say "Perfumed ".

Visibility rule when in darkness:
    if examining something, there is sufficient light;
    there is insufficient light.

Rule for printing the announcement of darkness: say "It is now pleasantly lightless in here." instead.

Rule for deciding the scope of the player while in darkness: place the location in scope.

To decide whether in daylight:
    if in darkness, no;
    yes.

Instead of sleeping when in daylight:
    say "You've never been able to sleep with the light on."

Instead of sleeping when the player can touch an audible thing (called the irritant):
    say "The steady [sound of the irritant] from [the irritant] prevents your slumber."

Instead of sleeping when the player can touch a scented thing (called the irritant):
    if the irritant is chocolate, say "The smell of chocolate continues to tantalize you, keeping you from sleep.";
    otherwise say "You sniffle. [The irritant] is probably acting on your allergies."

Instead of sleeping:
    say "You slip easily into the arms of Morpheus.";
    end the story finally saying "At last..."

When play begins:
    say "You have at last escaped from the airport and gotten through customs; survived an unnerving taxi ride over icy highways; stared down the impertinent concierge; endured the bellhop's catalog of features in your room; and achieved, finally, a moment of peace. Time for a good night's slumber!"

Test me with "x dreamcatcher / switch lamp off / look / sleep / eat chocolate / sleep / get plant / examine plant / open suitcase / put plant in suitcase / close suitcase / sleep / look / examine bose / switch bose off / sleep".

***ExampleFour Stars 1
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.

paste.png "Four Stars"

A thing has some text called sound. The sound of a thing is usually "silence".

The report listening rule is not listed in the report listening to rules.

Carry out listening to something:
    say "From [the noun] you hear [the sound of the noun]."

Instead of listening to a room:
    if an audible thing can be touched by the player, say "You hear [the list of audible things which can be touched by the player].";
    otherwise say "A merciful peace prevails."

Definition: a thing is audible if the sound of it is not "silence".

Before printing the name of something audible while listening to a room:
    say "[sound] from the "

A thing has some text called scent. The scent of a thing is usually "nothing".

The report smelling rule is not listed in the report smelling rulebook.

Carry out smelling something:
    say "From [the noun] you smell [scent of the noun]."

Instead of smelling a room:
    if a scented thing can be touched by the player, say "You smell [the list of scented things which can be touched by the player].";
    otherwise say "The place is blissfully odorless."

Definition: a thing is scented if the scent of it is not "nothing".

Before printing the name of something scented while smelling a room: say "[scent] from the "

The Waning Moon Resort is a dark room. "A spacious room with a flagstone floor, and a dreamcatcher hung over the king-size bed." The dreamcatcher is scenery in the Resort. The description is "The usual web of threads and crystals, feathers and beads." Instead of taking the dreamcatcher, say "Ah, ah -- you might be tempted to take it as a souvenir, except that the price list in the minibar clearly states they charge $65 apiece if you walk off with one. Cheaper than stealing the Frette bathrobes, but still probably not a good idea."

The king-size bed is an enterable supporter in the Resort. The description is "200-thread-count Egyptian cotton sheets, according to the website. You would make fun, only they really are extraordinarily comfortable." The player is on the bed. A Lindt chocolate is on the bed. It is edible. The scent of the chocolate is "chocolate-hazelnut smell".

Instead of exiting: say "You are too weary to move."

The suitcase is an openable closed container in the Resort.

An electric light is a kind of device. Carry out switching on an electric light: now the noun is lit. Carry out switching off an electric light: now the noun is unlit. Understand "light" as an electric light.

The solar lamp is an electric light in Waning Moon Resort. The description is "Specially designed to give light in a spectrum resembling sunlight, to improve the mood and make a person energetic." The lamp is switched on and lit.

An electric noisemaker is a kind of device. An electric noisemaker has some text called usual sound. The usual sound of an electric noisemaker is usually "beepbeepbeep". Carry out switching on an electric noisemaker: now the sound of the noun is the usual sound of the noun. Report switching on an electric noisemaker: say "[The noun] goes [usual sound of the noun]!" instead. Report switching off an electric noisemaker: say "You switch off [the noun], silencing the [usual sound of the noun]." instead.

Carry out switching off an electric noisemaker: now the sound of the noun is "silence".

The bedside table is in the Resort. The table supports a potted plant and a Bose speaker. The scent of the potted plant is "rosemary"

The Bose speaker is an electric noisemaker. The usual sound of the speaker is "soothing whalesong". The sound of the speaker is "soothing whalesong". The speaker is switched on.

Instead of touching a device: say "You feel the surface of [the noun] and discover the switch."

Instead of touching a scented thing: say "The brush of your fingers stirs loose a fresh cloud of [scent of the noun] smell."

Rule for printing the description of a dark room: try listening; try smelling; rule succeeds.

Instead of examining an audible thing while in darkness: try listening to the noun. Instead of examining something while in darkness: try touching the noun.

Before touching something when in darkness:
    say "You grope about..."

After inserting the plant into something:
    say "You unceremoniously dump [the noun] into [the second noun], hoping it sustains no important damage thereby."

Before printing the name of a dark room: if the player can touch an audible thing, say "Noisy "; if the player can touch a scented thing, say "Perfumed ".

Visibility rule when in darkness:
    if examining something, there is sufficient light;
    there is insufficient light.

Rule for printing the announcement of darkness: say "It is now pleasantly lightless in here." instead.

Rule for deciding the scope of the player while in darkness: place the location in scope.

To decide whether in daylight:
    if in darkness, no;
    yes.

Instead of sleeping when in daylight:
    say "You've never been able to sleep with the light on."

Instead of sleeping when the player can touch an audible thing (called the irritant):
    say "The steady [sound of the irritant] from [the irritant] prevents your slumber."

Instead of sleeping when the player can touch a scented thing (called the irritant):
    if the irritant is chocolate, say "The smell of chocolate continues to tantalize you, keeping you from sleep.";
    otherwise say "You sniffle. [The irritant] is probably acting on your allergies."

Instead of sleeping:
    say "You slip easily into the arms of Morpheus.";
    end the story finally saying "At last..."

When play begins:
    say "You have at last escaped from the airport and gotten through customs; survived an unnerving taxi ride over icy highways; stared down the impertinent concierge; endured the bellhop's catalog of features in your room; and achieved, finally, a moment of peace. Time for a good night's slumber!"

Test me with "x dreamcatcher / switch lamp off / look / sleep / eat chocolate / sleep / get plant / examine plant / open suitcase / put plant in suitcase / close suitcase / sleep / look / examine bose / switch bose off / sleep".

****ExampleCloak of Darkness
Implementation of "Cloak of Darkness", a simple example game that for years has been used to demonstrate the features of IF languages.