In the dark ... literally

Hi there,

here’s a quick example of what I tried to do (and failed):

"In the Dark" by HtF

Starting room is a room. [doh]
Test room is a dark room. "[if the test room is dark]A faint light glows from the wall, indicating the presence of a switch."

The iffy door is a door. It is north of starting room and south of test room.
Understand "door" as the iffy door.

The light switch is a thing in the test room. The light switch can be on or off. The light switch is off.

Instead of pushing the light switch:
	if the light switch is off:
		now the light switch is on;
		now test room is lit;
	otherwise:
		now the light switch is off;
		now test room is dark; 	[ I know this would be problematic, this is just for the test]

Definition: The Test room is dark if the iffy door is closed and the light switch is off.
Definition: The Test room is lit if the iffy door is open or the light switch is on.

[That is the, ahem, first amendment I made after I realised I could not do ANYTHING since it was dark]

after deciding the scope of the player:
	if the location of the player is the test room:
		place the iffy door in scope;
		place the light switch in scope;
		
[That is the, ahem, second amendment I made after I realised I could not do ANYTHING since it was dark]

visibility rule when doing anything in the test room:
	if the iffy door is closed and the light switch is off:
		Say "It *should* be lit, actually!";
		there is insufficient light;
	otherwise:
		Say "It *should be dark*!";
		there is sufficient light;
		
[That is the, third amendment I made after I realised I could not do ANYTHING since it was dark]

rule for writing a paragraph about the light switch:
	if the test room is dark, say "A faint light glows from the wall.";

No matter what - the only way I could toggle the room between lit and dark was by using the switch. My definitions don’t fire, my visibility rule is completely ignored and all things in the dark rooms are ignored as well. All examples I found were completely useless because they handled different things and usually required a “lit” item and did not have visibility based on an open door or something.

I tried to tackle the problem of the room being dark despite the open door by seeing what rules were used …

>n
[Rule "after deciding the scope of the player" applies.]
[Rule "standard set going variables rule" applies.]
[Rule "can't travel in what's not a vehicle rule" applies.]
[Rule "can't go through undescribed doors rule" applies.]
[Rule "can't go through closed doors rule" applies.]
(first opening the iffy door)
[Rule "can't open unless openable rule" applies.]
[Rule "can't open what's locked rule" applies.]
[Rule "can't open what's already open rule" applies.]
[Rule "standard opening rule" applies.]
[Rule "determine map connection rule" applies.]
[Rule "can't go that way rule" applies.]
[Rule "move player and vehicle rule" applies.]
[Rule "move floating objects rule" applies.]
[Rule "check light in new location rule" applies.]
[Rule "describe room gone into rule" applies.]

[Rule "determine visibility ceiling rule" applies.]
[Rule "room description heading rule" applies.]
Darkness

Now, I suspect that “check light in the new location rule” could handle the problem with the open door and the light switch and I guess the other rules might be helpful to have the dim glowing light switch appear (bacause of a pilot light in it) but I have NO CLUE how to see what these rules actually DO, see their code, their return code or anything. I even tried to write a new one but they never got triggered.

Since even google offerend 0 hits when using Inform “check light in the new location” this forum is my final hope that someone can tell me how to actually SEE and understand what all these rules that are mentioned when you activate rule tracing DO.

To see the Standard Rules, try

File menu > Open installed extension > Graham Nelson > Standard Rules

It looks like the “check light in new location rule” is:

Carry out an actor going (this is the check light in new location rule): if the actor is the player or the player is within the vehicle gone by or the player is within the thing gone with: surreptitiously reckon darkness.

Ah, that’s an eye opener - thanks!

Now I’ll have to see if I manage to find what “surreptitiously reckon darkness.” does when I’m back home. :slight_smile:

It would have been so much nicer (and easier) if the whole light/dark thing was not so messed up. If the game would understand:

lit = something seen in the dark
illuminate = to actively shine light on things which are not lit so that they can be seen in the dark as well

So things which are lit but are not illuminating would not light up the room but could be seen in the dark - without any coding by the author.

Sigh … am I being stuipid?

I followed the above hint and this is what I got:

Step 1- looking up the weird rule:

Carry out an actor going (this is the check light in new location rule): if the actor is the player, surreptitiously reckon darkness.

Step 2 - looking up the darkness reckoning thing:

To surreptitiously reckon darkness: (- SilentlyConsiderLight(); -).

Step 3 - looking up the light considering thing:

– nothing found –

This is like grigorrimax -> see katamumphus, katamumphus --> see qutiatl, qutiatl --> see grigorrimax

Anyone with an idea how to find out what SilentlyConsiderLight does … ?

Darkness is encoded deep within the Inform 6 core on which Inform 7 is built. This means that it is hard to mess with it. For instance, as you have found out, dark rooms simply print no room descriptions, so trying to print a certain room description if the room is dark will not work.

Messing with the Inform 6 core is best left to experts. But I think this code does what you want – if I understand your wishes correctly! Tell me if it doesn’t do what you’d like.

[code]“In the Dark” by HtF

Starting room is a room. [doh]
Test room is a dark room.

The iffy door is a door. It is north of starting room and south of test room.
Understand “door” as the iffy door.

After opening iffy door:
now test room is lit.

After closing iffy door:
if light switch is off:
now test room is dark.

The light switch is a thing in the test room. The light switch can be on or off. The light switch is off.

Instead of pushing the light switch:
if the light switch is off:
say “You push the switch. Phew, light!”;
now the light switch is on;
now test room is lit;
otherwise:
now the light switch is off;
if iffy door is closed:
now test room is dark;
say “You push the switch. Oops, darkness!”;
otherwise:
say “The electric lights go off, but luckily there’s still the open door.”

after deciding the scope of the player:
if the location of the player is the test room:
place the iffy door in scope;
place the light switch in scope;

After looking in the test room:
if the test room is dark, say “A faint light glows from the wall, indicating the presence of a switch.”;

Test me with “n / close door / l / push switch / push switch / open door”.[/code]

So you’re trying to have a “slightly” lit switch in a dark room, which becomes lit after turning on the switch or opening the door, right?

I played around and discovered a “Can’t act in the dark” rule (which blocks examining, but does not block other activities which I believe don’t have the “requires light” designation). Here’s what I did:

[rant][code]“In the Dark” by Hanon

Test Room is a dark room. “What a pleasant, brightly-lit room!”.

After looking when the location is test room:
if in darkness:
say “Some light in here would help out a lot. There’s a faintly glowing switch over there.”

A light switch is a device in test room. It is fixed in place. The description is “[if the location is dark]It glows amber from within, just enough to see it but not light anything but the edge of a door next to it.[otherwise]It’s the switch that controls the lighting in the room.[end if]”

The can’t act in the dark rule does nothing when examining the light switch.

Victory Room is a room.

a plain door is a door. It is north of Test Room and south of victory room.

After deciding the scope of the player when the location is Test Room:
if test room is dark:
place light switch in scope;
place plain door in scope.

Carry out opening plain door:
if test room is dark:
now test room is lit.

Carry out closing plain door:
if test room is lit:
now test room is dark.

Carry out switching on light switch:
now light switch is lit.

Carry out switching off light switch:
now light switch is not lit.[/code]

[/rant]
Victor’s version works also, but by overriding all rules using an INSTEAD. Handy if you’re dealing with light and dark rooms to know the “can’t act in the dark” rule and the “if in darkness” check which determines any light source nearby regardless whether the room itself is dark. It’s probably weird that I made the light switch itself light up - it would have made more sense if I had made a device called ‘a lamp’ or “the lights” as a switchable device. There’s a way to make a separate object that lights up controlled by a switch and not have the switch itself emit light, but that gets really complicated with naming if you have multiples - I wrestled with that a lot in a previous game with lots of lights and switches.

Others have already responded to the substantive aspects. So just to respond to one query, you can find SilentlyConsiderLight here:

inform7.com/sources/src/i6templa … ndix-B.pdf

Specifically, under the section “§5. Silent Light Consideration.” I’m not sure if that implementation is still in use but at least it sheds some light (pun somewhat intended) on what you are discovering as you do some source code archaeology.

Thanks all for the help - I attached the direct control of the room being lit or not to both the switch and the door, as you two did.

I now know I have (at least) three ways to fiddle with “darkness reports”:

Before printing the description of a dark room:

Rule for printing the description of a dark room:

After looking when the location is test room:

One thing I noticed that if you try to correct the lit or dark condition (as I tried with my definitions) in the BEFORE PRINTING and do NOT tie it to the switch and door instead, Inform does two sequential looks - one in (Darkness) and then one in Test Room, which is a tad weird.

So I have to take care to not change the light condition mid-rule within a looking or printing event. :slight_smile: Inform catches me doing this and “rewards” me with the before and after messages.

Backing up, I note that you wrote

Definition: The Test room is dark if the iffy door is closed and the light switch is off.
Definition: The Test room is lit if the iffy door is open or the light switch is on.

This doesn’t do what you want. In fact it get ignored entirely. The term “lit” is defined in the Standard Rules, as a settable binary property: “A thing can be lit or unlit.” The system can’t handle two contradictory definitions.

You may want to check chapter 6 from the Inform game Bronze’s source code. It can handle light sources that are in adjacent rooms and shine into the dark room.

Copied from the start of the chapter:
[Darkness in Bronze is a bit more complicated than average because we take into account what can be heard, and also whether there is a light source in a room that might be shining into the dark one. So we set some general rules for it here:]

Google “Bronze Emily Short”.

Hope this helps

So, let’s start over and set this up in the simplest (or least hacky, anyhow) way possible.

Starting room is a room.

Test room is a dark room.

[Create a third room to make sure "normal" darkness hasn't changed.]
Permanently-dark room is a dark room. It is east of the starting room.

The iffy door is a door. It is north of starting room and south of test room.
Understand "door" as the iffy door.

[Alter the room lighted/dark condition each time the door is opened or closed. We continue the action to allow the normal "You open the door" messages.]

After opening the iffy door:
	now the test room is lighted;
	continue the action.

After closing the iffy door:
	now the test room is dark;
	continue the action.

["Device" means it has a switched on / switched off property.]
The light switch is a fixed in place device in the test room.

[Accept "push switch" in addition to the normal "switch on / switch off switch" grammar.]
Instead of pushing the light switch:
	if the light switch is switched off:
		try switching on the light switch;
	otherwise:
		try switching off the light switch;

[Alter the switch lit/unlit condition each time it's toggled. Note that this is independent of the room lighted/dark condition!]

After switching on the light switch:
	now the light switch is lit;
	say "The light comes on."

After switching off the light switch:
	now the light switch is unlit;
	say "The light goes out."

Rule for printing the description of a dark room when the location is the test room:
	instead say "It is pitch dark, but you can see the outline of a light switch."

[Make sure the switch is in scope regardless of illumination.]
After deciding the scope of the player while the location is the test room:
	place the light switch in scope.

We let the standard illumination rules operate, based on two things. (1) The light switch becomes a light source (“lit”) when turned on. (2) The room itself becomes lighted when the door is open.

You probably want to do more work on this. For example, you can’t EXAMINE SWITCH in the dark (that will require a visibility rule). And the light switch is labelled “(providing light)” when the door is closed, which you might want to squash. But this covers your original goals.