Differentiating from more than one thing

I scanned through similar problems and found them to be much more complicated than what I am trying to do. I want to allow the player to blow out any or all of three lanterns, but using a generalized rule. I read through the Zorn of Zorna (#347) example in the documentation and couldn’t make heads or tails of it. Multiple candles can be lit or unlit, but they are treated like one candle? I want to light or blow out lanterns without specifying them exactly. The following code works but is egregious:

A lantern is a kind of thing. A lantern is either lit or unlit. 
Description of generic lantern is "A glass-enclosed wick on a metal reservoir of some kind. On the reservoir is a hand-written note in large block letters: [line break]DANGER: DO NOT EXTINGUISH.[line break]".

The south lantern is in the embalming room. "[if lit]A lantern shines on a cabinet along the south wall.[else]The south lantern sits in darkness.".
The north lantern is in the embalming room. "[if lit]A lantern shines on a cabinet along the north wall.[else]The north lantern sits in darkness.".
The west lantern is in the embalming room. "[if lit]A lantern shines on a cabinet along the south wall.[else]The west lantern sits in darkness.".

The south lantern is lit.
The north lantern is lit.
The west lantern is lit.

Instead of looking when embalming room is dark:
	say "Without the lanterns, it is too dark to see anything. [line break]Do you smell something?".

Description of south lantern is "[description of generic lantern][if lit]A flame flickers within the glass[else]The charred wick sheds no light.". 
Description of north lantern is "[description of generic lantern][if lit]A flame flickers within the glass[else]The charred wick sheds no light.".
Description of west lantern is "[description of generic lantern][if lit]A flame flickers within the glass[else]The charred wick sheds no light.".

Definition: Embalming room is dark if north lantern is unlit and south lantern is unlit and west lantern are unlit.

[Instead of blowing out something: 
	if [the noun] is unlit:
		say "That lantern is already out.";
		stop the action;
	otherwise:
		now [the noun] is unlit; 
		say "You put out [the noun]. A small thread of smoke rises as the wick cools.";
]

Blowing out is an action applying to one thing.
Understand "blow out [something]" or "extinguish [something]" or "put out [something]" as blowing out. 

	Instead of blowing out west lantern: 
	if the west lantern is unlit:
		say "That lantern is already out.";
		stop the action;
	otherwise:
		now the west lantern is unlit; 
		say "You put out [the noun]. A small thread of smoke rises as the wick cools.";

Instead of blowing out north lantern: 
	if the north lantern is unlit:
		say "That lantern is already out.";
		stop the action;
	otherwise:
		now the north lantern is unlit; 
		say "You put out [the noun]. A small thread of smoke rises as the wick cools.";

Instead of blowing out south lantern: 
	if the south lantern is unlit:
		say "That lantern is already out.";
		stop the action;
	otherwise:
		now the south lantern is unlit; 
		say "You put out [the noun]. A small thread of smoke rises as the wick cools.";

Isn’t there something simpler?
Note the commented code block about "Instead of blowing out something…] which does not work.

I can’t test this right now, but here’s a guess:

Instead of three separate rules for blowing out different lanterns, try just one “instead of blowing out a lantern” rule. I forget how to word it exactly, but I would guess either

Instead of blowing out (L - a lantern):

or it might be

Instead of blowing out a lantern (called L):

Then you can probably say thing like

now the L is unlit

within the rule.

Also, I think you can say

The description of a lantern is usually “whatever.”

instead of giving three identical descriptions.

Also, if it’s not recognizing the lanterns as lanterns, you may need to say

The north lantern is a lantern.

and so on.

1 Like

Try this:

The embalming room is a dark room.

A lantern is a kind of thing. A lantern has a direction called the wall-location.

The initial appearance of a lantern is "[if lit]A lantern shines on a cabinet along the [wall-location] wall.[else]The [wall-location] lantern sits in darkness."

The south lantern is a lantern in the embalming room. It is lit. The wall-location is south.
The north lantern is a lantern in the embalming room. It is lit. The wall-location is north.
The west lantern is a lantern in the embalming room. It is lit. The wall-location is west.


Description of a lantern is "A glass-enclosed wick on a metal reservoir of some kind. On the reservoir is a hand-written note in large block letters: [line break]DANGER: DO NOT EXTINGUISH.[line break][if lit]A flame flickers within the glass[else]The charred wick sheds no light[end if].". 

Definition: Embalming room is dark if north lantern is unlit and south lantern is unlit and west lantern are unlit.

Blowing out is an action applying to one thing.
Understand "blow out [something]" or "extinguish [something]" or "put out [something]" as blowing out. 

Check blowing out a lantern:
	if the noun is unlit:
		say "That lantern is already out." instead;
		
Check blowing out something when the noun is not a lantern:
	say "That accomplishes nothing." instead;

Carry out blowing out a lantern:
	now noun is unlit; 
		
Report blowing out a lantern:
	say "You put out [the noun]. A small thread of smoke rises as the wick cools.";

edit: using inform darkness functionality.

3 Likes

If you make the embalming room a dark room as @rileypb has done, you no longer need this:

Definition: Embalming room is dark if north lantern is unlit and south lantern is unlit and west lantern are unlit.

Since that will naturally be true if no lanterns are lit and the player carries no light source, and these are things which can already be tested for.

2 Likes

Oops! you are exactly right.

A quick note on this: The condition if the embalming room is dark tests only whether the embalming room has the darkness attribute. It will be true even if the room contains lit lanterns or some other light source. Something like if no lanterns in the embalming room are lit will test for the actual absence of light.

Or in general if in darkness.

Or if you want an effect specifically in the embalming room: if in darkness and location is embalming room

1 Like

in darkness is of course true only if the player is in darkness (and if the player is in a closed opaque enterable container, in darkness may be true even if the player’s location is lit).

The Inform documentation contains a sneaky trick for determining if any place other than the player’s immediate surroundings are in darkness, by teleporting a ‘light meter’ to said place to report on its findings:

Recipe Book §3.7. Lighting; Example 81: Unblinking

1 Like

You were looking for tips to reduce duplication/redundancy and phrase things more concisely, I think.

This is how I would have coded this room:

The Embalming Room is a dark room. 
A lantern is a kind of thing with description "A glass-enclosed wick on a metal reservoir of some kind. On the reservoir is a hand-written note in large block letters: [line break]DANGER: DO NOT EXTINGUISH.[line break][if lit]A flame flickers within the glass[else]The charred wick sheds no light."."[if lit]A lantern shines on a cabinet along the [word number one in printed name] wall.[else][The item described] sits in darkness.".
The south lantern, the north lantern and the west lantern are lit lanterns in the Embalming Room.

Rule for printing the description of a dark room when the location is the embalming room:
	say "Without the lanterns, it is too dark to see anything. [line break]Do you smell something?".

Blowing out is an action applying to one thing.
Understand "blow out [something]" or "extinguish [something]" or "put out [something]" as blowing out. 

Check blowing out an unlit thing:
	say "[We] can only put out things which are lit." instead.
Carry out blowing out:
	now the noun is unlit.
Report blowing out:
	say "[We] [put] out [the noun][if the noun is a lantern]. A small thread of smoke rises as the wick cools[end if].".
4 Likes

Phil,
Your code really makes it clear. Thanks much. I’ll give that a try.
-abc

“I fear for my country when I reflect that God is just.”
– T.E. Lawrence (Lawrence of Arabia)

| Phil Riley rileypb IFComp 2022 Participant
February 6 |

  • | - |

Try this:

The embalming room is a dark room.

A lantern is a kind of thing. A lantern has a direction called the wall-location.

The initial appearance of a lantern is "[if lit]A lantern shines on a cabinet along the [wall-location] wall.[else]The [wall-location] lantern sits in darkness."

The south lantern is a lantern in the embalming room. It is lit. The wall-location is south.
The north lantern is a lantern in the embalming room. It is lit. The wall-location is north.
The west lantern is a lantern in the embalming room. It is lit. The wall-location is west.

Description of a lantern is "A glass-enclosed wick on a metal reservoir of some kind. On the reservoir is a hand-written note in large block letters: [line break]DANGER: DO NOT EXTINGUISH.[line break][if lit]A flame flickers within the glass[else]The charred wick sheds no light[end if].". 

Definition: Embalming room is dark if north lantern is unlit and south lantern is unlit and west lantern are unlit.

Blowing out is an action applying to one thing.
Understand "blow out [something]" or "extinguish [something]" or "put out [something]" as blowing out. 

Check blowing out a lantern:
	if the noun is unlit:
		say "That lantern is already out." instead;
		
Check blowing out something when the noun is not a lantern:
	say "That accomplishes nothing." instead;

Carry out blowing out a lantern:
	now noun is unlit; 
		
Report blowing out a lantern:
	say "You put out [the noun]. A small thread of smoke rises as the wick cools.";

edit: using inform darkness functionality.

Dr. Peter Bates,
Thank you. I will try this an let you know.
-abc

“I fear for my country when I reflect that God is just.”
– T.E. Lawrence (Lawrence of Arabia)

| Dr Peter Bates drpeterbatesuk
February 7 |

  • | - |

You were looking for tips to reduce duplication/redundancy and phrase things more concisely, I think.

This is how I would have coded this room:

The Embalming Room is a dark room. 
A lantern is a kind of thing with description "A glass-enclosed wick on a metal reservoir of some kind. On the reservoir is a hand-written note in large block letters: [line break]DANGER: DO NOT EXTINGUISH.[line break][if lit]A flame flickers within the glass[else]The charred wick sheds no light."."[if lit]A lantern shines on a cabinet along the [word number one in printed name] wall.[else][The item described] sits in darkness.".
The south lantern, the north lantern and the west lantern are lit lanterns in the Embalming Room.

Rule for printing the description of a dark room when the location is the embalming room:
	say "Without the lanterns, it is too dark to see anything. [line break]Do you smell something?".

Blowing out is an action applying to one thing.
Understand "blow out [something]" or "extinguish [something]" or "put out [something]" as blowing out. 

Check blowing out an unlit thing:
	say "[We] can only put out things which are lit." instead.
Carry out blowing out:
	now the noun is unlit.
Report blowing out:
	say "[We] [put] out [the noun][if the noun is a lantern]. A small thread of smoke rises as the wick cools[end if].".

drpeterbatesuk: I gave that a try. For some reason, it doesn’t recognize the three lit lanterns in the embalming room, so I get no room description (just the dark message.) This seemed to connect ‘dark room’ with lit lanterns:

Definition: A room is dark if all lanterns are unlit.

Well, that’s a bit odd. You really shouldn’t have to redefine what dark means. Inform works that out for itself. Have you got other places where you’re defining dark in your story? This isn’t something it’s good to do- I’d remove all such definitions.

I assume my code works fine if it’s pasted into a new, blank project? It does for me…

EDIT: I should say that redefining the meaning of ‘dark’ for rooms like this:

Definition: A room is dark if all lanterns are unlit.

should only affect the result of conditions you write such as ‘if the embalming room is dark’ or ‘when the location is dark’- overriding the usual meaning of ‘dark’ for rooms, which would usually depend on the status of the room’s lighted/dark property, rather than on lanterns being lit or unlit.

This redefinition should have no effect on Inform’s inbuilt handling of darkness, and in particular does not change the lighted/dark property of rooms from lighted to dark when all the lanterns are unlit.

I am using Inform 10 and I notice that there are some differences. I had to revise a few lines of code here and there (still doing so for my large source file) to get what was working with I7 to work with I10. If I take out that above Definition, it does not compile. I thought that the Definition only defines dark when all lanterns were unlit, and not Dark in general.

I will be putting a lit candle in the hands of Player when I enter the room next. The room may still be dark, but look will work since there is “some” light. I will see how that works out. Perhaps I can figure out a way to remove the Definition.

drpeterbates: I ran your code again. All the rules and actions work, and I get the default Dark message ("It is pitch dark now!). However, there was no description to the room. When I put one in, it said it was too dark to see anything, even with the lanterns lit. With the lanterns out, I could still EXAMINE them. The definition solved this problem.

I think you’ve got something very odd going on here that is linked to something elsewhere in you source code. It’s difficult to comment further without being able to look at that to see where the problem lies. The code I posted works as expected as a standalone room in both Ver 10 and the previous versions.

In particular, it’s odd that you were able to examine the lanterns when Inform was telling you you were in pitch darkness. That shouldn’t normally be possible.

I thought that the Definition only defines dark when all lanterns were unlit, and not Dark in general.

As I suggested previously, that definition shouldn’t affect darkness at all (i.e. whether the player finds themselves in the pitch dark and unable to see), unless your source or an extension you are using has code elsewhere that changes the usual routines Inform uses to determine darkness. Darkness is usually controlled by whether rooms and the objects in them have the lighted/lit vs dark/unlit property and your definition would not usually affect that property for any room or object in any way.

This is the code I am using, and the transcript I get in both Ver 10 and previous versions:
(It also compiles and runs exactly the same whether that definition is included in it or not)

"Embalming_Room" by PB

The Embalming Room is a dark room. 
A lantern is a kind of thing with description "A glass-enclosed wick on a metal reservoir of some kind. On the reservoir is a hand-written note in large block letters: [line break]DANGER: DO NOT EXTINGUISH.[line break][if lit]A flame flickers within the glass[else]The charred wick sheds no light."."[if lit]A lantern shines on a cabinet along the [word number one in printed name] wall.[else][The item described] sits in darkness.".
The south lantern, the north lantern and the west lantern are lit lanterns in the Embalming Room.

Rule for printing the description of a dark room when the location is the embalming room:
	say "Without the lanterns, it is too dark to see anything. [line break]Do you smell something?".

Blowing out is an action applying to one thing.
Understand "blow out [something]" or "extinguish [something]" or "put out [something]" as blowing out. 

Check blowing out an unlit thing:
	say "[We] can only put out things which are lit." instead.
Carry out blowing out:
	now the noun is unlit.
Report blowing out:
	say "[We] [put] out [the noun][if the noun is a lantern]. A small thread of smoke rises as the wick cools[end if].".


Test me with "blow out north/blow out west/blow out south/look".

Embalming_Room
An Interactive Fiction by PB
Release 1 / Serial number 230208 / Inform 7 v10.1.2 / D

Embalming Room
A lantern shines on a cabinet along the south wall.

A lantern shines on a cabinet along the north wall.

A lantern shines on a cabinet along the west wall.

>test me
(Testing.)

>[1] blow out north
(the north lantern)
You put out the north lantern. A small thread of smoke rises as the wick cools.

>[2] blow out west
(the west lantern)
You put out the west lantern. A small thread of smoke rises as the wick cools.

>[3] blow out south
(the south lantern)
You put out the south lantern. A small thread of smoke rises as the wick cools.

It is now pitch dark in here!

>[4] look
Darkness
Without the lanterns, it is too dark to see anything.
Do you smell something?

>

Do you still have this line somewhere?

Instead of looking when embalming room is dark:
	say "Without the lanterns, it is too dark to see anything. [line break]Do you smell something?".

Without your definition, this will always prevent normal looking in the embalming room when (as in my code) the embalming room has been declared as (by default, i.e. in the absence of any lit things) dark, and display this text instead.

The reason is that ‘when embalming room is dark’ will usually look at the lighted/dark property for the room, not whether the room is in darkness. A room with the lighted/dark property set to dark will fire this rule even when, because lit things are in it, the room is not in darkness - which is the situation with my code for the embalming room. The room is (by default) dark, but darkness is initially prevented by the three lit lanterns in it.

With your definition, ‘when embalming room is dark’ no longer looks at the room’s lighted/dark property, but rather at whether the lanterns are lit- so this rule won’t fire until all the lanterns are extinguished.

Try getting rid of the line above (which is redundant to my code, which prints the dark room description using the ‘printing the description of a dark room’ activity- see the Activities chapter in the documentation), and your definition line, and see what happens…

EDIT: it doesn’t help that Inform itself conflates ‘dark’ and ‘in darkness’ in the name of this activity, which should really be called ‘printing the description of a room in darkness’- the activity doesn’t (necessarily) apply in a dark room, it only applies when a room is in darkness.

EDIT2: I notice that the documentation can also appear a little misleading about the flexibility of this activity, making the following comment

(Note that this activity does not come in different forms for different dark rooms: the wording is fixed at “printing the description of a dark room”, and we are not allowed to substitute particular dark rooms or assign a “(called …)” onto the mention of the dark room.)

which suggests on a cursory reading that there is no way to tailor the description to different situations or rooms.

While it’s true that the rule description “printing the description of a dark room” can’t be changed, you can append “when the location is…” for example, to provide different rules for different locations, and you can also elaborate more complex rules in the usual way:

Rule for printing the description of a dark room when the location is the embalming room:
	say "Pressed in on all sides by Stygian blackness, you fancy you can faintly hear the soft scuttling and chittering of ten thousand nameless horrors...";
	if the torch is carried:
		say "You grope frantically for your torch.".
1 Like

PB: Thanks for spending so much time with me on this topic. I get the same result as your posted transcript. However, without the Definition and with the lanterns lit, LOOK doesn’t give a description of the room. It says it is too dark. That’s not right. Can you try the case with a room description?

I think my definition is that the embalming room is more specific than the regular darkness rule and overrides it. Other rooms would not be affected. I will have to study your example for the difference between printing description and merely descriptions of room, dark or otherwise.

It’s no trouble.

This is what I get with a room description:

Embalming_Room
An Interactive Fiction by PB
Release 1 / Serial number 230209 / Inform 7 v10.1.2 / D

Embalming Room
Lanterns flicker smokily, sending shadows leaping in the darker recessses of this square chamber.

A lantern shines on a cabinet along the south wall.

A lantern shines on a cabinet along the north wall.

A lantern shines on a cabinet along the west wall.

>

If you’re seeing all of this except for the room description, you’ve got a rule somewhere elsewhere in your code which is interfering with the standard rules for printing the description of a room.

If it was an Instead of looking... rule you wouldn’t be seeing the initial appearances of the lanterns either.

EDIT: Are you using any extensions?

Dr Peter Bates,
Hmmm. Not sure what is different. Are you on a Mac or Windows machine. Are you running Inform 7 or Inform 10?
-Falsoon2

“After the game, both the pawn and the king go back into the box.”
– Persian proverb

| Dr Peter Bates drpeterbatesuk
February 9 |

  • | - |

It’s no trouble.

This is what I get with a room description:

Embalming_Room
An Interactive Fiction by PB
Release 1 / Serial number 230209 / Inform 7 v10.1.2 / D

Embalming Room
Lanterns flicker smokily, sending shadows leaping in the darker recessses of this square chamber.

A lantern shines on a cabinet along the south wall.

A lantern shines on a cabinet along the north wall.

A lantern shines on a cabinet along the west wall.

If you’re seeing all of this except for the room description, you’ve got a rule somewhere elsewhere in your code which is interfering with the standard rules for printing the description of a room.

If it was an Instead of looking... rule you wouldn’t be seeing the initial appearances of the lanterns either.