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

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

WI
80
*** 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

"Cloak of Darkness" is a brief example game that has been implemented in nearly every IF system currently used. It hasn't got much claim to complexity or richness, but it does exemplify many of the standard things one might want an IF language to be able to do: define descriptions and the results of actions, assign synonyms to nouns, create new verbs, handle darkness, track repeated acts, and so on.

Here is what the game looks like in Inform:

"Cloak of Darkness"

The story headline is "A basic IF demonstration."

The maximum score is 2.

Whatever room we define first becomes the starting room of the game, in the absence of other instructions:

Foyer of the Opera House is a room. "You are standing in a spacious hall, splendidly decorated in red and gold, with glittering chandeliers overhead. The entrance from the street is to the north, and there are doorways south and west."

Instead of going north in the Foyer, say "You've only just arrived, and besides, the weather outside seems to be getting worse."

We can add more rooms by specifying their relation to the first room. Unless we say otherwise, the connection will automatically be bidirectional, so "The Cloakroom is west of the Foyer" will also mean "The Foyer is east of the Cloakroom":

The Cloakroom is west of the Foyer. "The walls of this small room were clearly once lined with hooks, though now only one remains. The exit is a door to the east."

In the Cloakroom is a supporter called the small brass hook. The hook is scenery. Understand "peg" as the hook.

Inform will automatically understand any words in the object definition ("small", "brass", and "hook", in this case), but we can add extra synonyms with this sort of Understand command.

The description of the hook is "It's just a small brass hook, [if something is on the hook]with [a list of things on the hook] hanging on it[otherwise]screwed to the wall[end if]."

This description is general enough that, if we were to add other hangable items to the game, they would automatically be described correctly as well.

The Bar is south of the Foyer. The printed name of the bar is "Foyer Bar". The Bar is dark. "The bar, much rougher than you'd have guessed after the opulence of the foyer to the north, is completely empty. There seems to be some sort of message scrawled in the sawdust on the floor."

The scrawled message is scenery in the Bar. Understand "floor" or "sawdust" as the message.

Neatness is a kind of value. The neatnesses are neat, scuffed, and trampled. The message has a neatness. The message is neat.

We could if we wished use a number to indicate how many times the player has stepped on the message, but Inform also makes it easy to add descriptive properties of this sort, so that the code remains readable even when the reader does not know what "the number of the message" might mean.

Instead of examining the message:
    increment score;
    say "The message, neatly marked in the sawdust, reads...";
    end the story finally.

This second rule takes precedence over the first one whenever the message is trampled. Inform automatically applies whichever rule is most specific:

Instead of examining the trampled message:
    say "The message has been carelessly trampled, making it difficult to read. You can just distinguish the words...";
    end the story saying "You have lost".

This command advances the state of the message from neat to scuffed and from scuffed to trampled. We can define any kinds of value we like and advance or decrease them in this way:

Instead of doing something other than going in the bar when in darkness:
    if the message is not trampled, now the neatness of the message is the neatness after the neatness of the message;
    say "In the dark? You could easily disturb something."

Instead of going nowhere from the bar when in darkness:
    now the message is trampled;
    say "Blundering around in the dark isn't a good idea!"

This defines an object which is worn at the start of play. Because we have said the player is wearing the item, Inform infers that it is clothing and can be taken off and put on again at will.

The player wears a velvet cloak. The cloak can be hung or unhung. Understand "dark" or "black" or "satin" as the cloak. The description of the cloak is "A handsome cloak, of velvet trimmed with satin, and slightly splattered with raindrops. Its blackness is so deep that it almost seems to suck light from the room."

Carry out taking the cloak:
    now the bar is dark.

Carry out putting the unhung cloak on something in the cloakroom:
    now the cloak is hung;
    increment score.

Carry out putting the cloak on something in the cloakroom:
    now the bar is lit.

Carry out dropping the cloak in the cloakroom:
    now the bar is lit.

Instead of dropping or putting the cloak on when the player is not in the cloakroom:
    say "This isn't the best place to leave a smart cloak lying around."

When play begins:
    say "[paragraph break]Hurrying through the rainswept November night, you're glad to see the bright lights of the Opera House. It's surprising that there aren't more people about but, hey, what do you expect in a cheap demo game...?"

Understand "hang [something preferably held] on [something]" as putting it on.

Test me with "s / n / w / inventory / hang cloak on hook / e / s / read message".

And that's all. As always, type TEST ME to watch the scenario play itself out.


PreviousContentsNext