Well, the point of Draconis’s comment was that you should leave the dark/lighted/unlit/lit properties as the things the game uses to handle whether the player can see in a particular room. (Which determines whether you get messages like “It is pitch dark…”) You should leave those alone–don’t try to turn the “dark” property off and on by hand based on a calculation as to whether you think it’s lit up by something, let it stay “dark” (that is, not naturally lit) and let Inform figure out whether it’s got light in it by itself.
The reason you need the other properties is to calculate whether a room is lit up–naturally lighted or containing a light source. So those should just go in your check rules.
So I’d rewrite this like this, using the definitions I gave:
[code]Definition: A room is light-enclosing if it encloses a lit thing.
Definition: A room is light-filled if it is lit or it is light-enclosing.
Definition: A room is truly dark if it is not light-filled.
Rule for printing the description of a dark room: [OK, this one is confusing. The name of the activity is “printing the description of a dark room,” but it’s not actually for any room that has the property “dark”; it’s really a rule for looking in darkness. There isn’t any corresponding activity “printing the description of a lighted room” or anything like that. See Writing with Inform §18.22]
if an adjacent room is light-filled:
repeat with that way running through directions:
if the room that way from the location is light-filled:
say “It is pitch dark, and you can’t see a thing… except for a faint light coming from the [that way].”;
otherwise:
say “It is pitch dark, and you can’t see a thing.” instead. [you don’t actually need the “instead” here, since it’s an activity–running one “for” rule for an activity automatically preempts all other “for” rules for the activity]
Before going from a truly dark room when the room gone to is truly dark:
if an adjacent room is lit:
repeat with that way running through directions:
if the room that way from the location is lit: [we don’t need the “if that way is the noun” check, because we already checked whether the room gone to is truly dark.]
say “It is not wise to continue on in darkness. You can make out a faint light coming from the [that way].” instead;
otherwise:
if the blindturns of the player is less than 15:
now the blindturns of the player is the blindturns of the player plus 1; [there’s also a shorthand phrase for this, “increment the blindturns of the player”]
say “It’s not a good idea to go blundering about in the dark, you could trip over something and have a nasty fall.”;
otherwise:
say “Whilst blundering about in the darkness (an activity which can only be described as [’]not a good idea[’]), you trip over something and crash to the floor, smashing your head on something very hard on the way. So hard in fact, you are knocked unconscious and fall into a coma… from which, you do not awaken.”;
end the story saying “You have died. Bad Ending(Nasty Fall)” instead.
[and note that you don’t need the “After going” rule at all, because you’re not trying to adjust the darkness rules by hand][/code]
This saves you a lot of logic, means you don’t have to adjust darkness by hand, and prevents you from having weird effects elsewhere.
Here it is in a scenario. (By the way, if you paste code directly from the IDE into the forum, it’ll preserve your tab stops–you should be able to paste this directly in and have the tab stops work.)
[code]A room is usually dark.
Cave Mouth is a lighted room. Outer Cave is west of Cave Mouth. Central Cave is west of Outer Cave. Alcove is north of Central Cave. Inner Cave is west of Central Cave.
A lamp is a kind of device. A lamp is usually fixed in place. A lamp is usually switched on. A lamp is usually lit. [these just ensure that the lamps are all switched on and lit at the beginning of the game.] One lamp is in every room.
The flashlight is a lamp. The flashlight is portable. The flashlight is switched off. The flashlight is not lit. The player carries the flashlight. [Otherwise we’d never be able to switch a lamp back on, because we couldn’t see it.]
Carry out switching off a lamp (called lantern): now the lantern is not lit.
Carry out switching on a lamp (called lantern): now the lantern is lit.
The player has a number called blindturns.
Definition: A room is light-enclosing if it encloses a lit thing.
Definition: A room is light-filled if it is lit or it is light-enclosing.
Definition: A room is truly dark if it is not light-filled.
Rule for printing the description of a dark room: [OK, this one is confusing. The name of the activity is “printing the description of a dark room,” but it’s not actually for any room that has the property “dark”; it’s really a rule for looking in darkness. There isn’t any corresponding activity “printing the description of a lighted room” or anything like that. See Writing with Inform §18.22]
if an adjacent room is light-filled:
repeat with that way running through directions:
if the room that way from the location is light-filled:
say “It is pitch dark, and you can’t see a thing… except for a faint light coming from the [that way].”;
otherwise:
say “It is pitch dark, and you can’t see a thing.” instead. [you don’t actually need the “instead” here, since it’s an activity–running one “for” rule for an activity automatically preempts all other “for” rules for the activity]
Before going from a truly dark room when the room gone to is truly dark:
if an adjacent room is light-filled:
repeat with that way running through directions:
if the room that way from the location is lit: [we don’t need the “if that way is the noun” check, because we already checked whether the room gone to is truly dark.]
say “It is not wise to continue on in darkness. You can make out a faint light coming from the [that way].” instead;
otherwise:
if the blindturns of the player is less than 15:
now the blindturns of the player is the blindturns of the player plus 1; [there’s also a shorthand phrase for this, “increment the blindturns of the player”]
say “It’s not a good idea to go blundering about in the dark, you could trip over something and have a nasty fall. (You’ve been doing this for [blindturns of the player] turns.)”;
otherwise:
say “Whilst blundering about in the darkness (an activity which can only be described as [’]not a good idea[’]), you trip over something and crash to the floor, smashing your head on something very hard on the way. So hard in fact, you are knocked unconscious and fall into a coma… from which, you do not awaken.”;
end the story saying “You have died. Bad Ending(Nasty Fall)” instead.[/code]
There are also a few problems in the code. One is that a room is getting set to dark/lit only when the player has visited it, so if there are some rooms that start out dark with a light source they will register as dark when you check them… which will mean that the player won’t be able to go to them when they should, and that they won’t show up as adjacent rooms from which light is coming.
Another is that you have some loops over directions that stop (with “instead”) as soon as they encounter a non-lit room, when they really should be going and gathering all the adjacent non-lit rooms.
Another is that in the “Before going” rule, if the loop hits a direction with an adjacent room, it’ll stop and print a message about that even when the room the player is trying to go to is lit. (The loop over directions starts with north, so when you’re in the central cave you always get messages about the alcove even though you should be able to go to the inner cave if its lamp is on.)
And finally, you have an “After going” rule with a missing “continue the action” in one place, which cuts off the report going rule that prints the description of the new room. You could solve this by adding a “continue the action,” but it’d be better to just make it a Carry out going.
[code]A room is usually dark.
Cave Mouth is a lighted room. Outer Cave is west of Cave Mouth. Central Cave is west of Outer Cave. Alcove is north of Central Cave. Inner Cave is west of Central Cave.
A lamp is a kind of device. A lamp is usually fixed in place. A lamp is usually switched on. A lamp is usually lit. [these just ensure that the lamps are all switched on and lit at the beginning of the game.] One lamp is in every room.
The flashlight is a lamp. The flashlight is portable. The flashlight is switched off. The flashlight is not lit. The player carries the flashlight. [Otherwise we’d never be able to switch a lamp back on, because we couldn’t see it.]
Carry out switching off a lamp (called lantern): now the lantern is not lit.
Carry out switching on a lamp (called lantern): now the lantern is lit.
The player has a number called blindturns.
A room can be naturallylit. A room is usually not naturallylit. Cave Mouth is naturallylit.
Every turn:
if the location is not naturallylit:
if the location does not enclose a lit thing:
now the location is dark;
otherwise:
now the location is not dark.
Rule for printing the description of a dark room:
if an adjacent room is lit:
repeat with that way running through directions:
if the room that way from the location is lit:
say “It is pitch dark, and you can’t see a thing… except for a faint light coming from the [that way].”;
otherwise:
say “It is pitch dark, and you can’t see a thing.” instead. [if room in the first direction you check is not lit, this interrupts the loop before you get to anything else]
Before going when the location is a dark room:
if an adjacent room is lit:
repeat with that way running through directions:
if the room that way from the location is lit:
if that way is the noun:
continue the action;
otherwise:
say “It is not wise to continue on in darkness. You can make out a faint light coming from the [that way].” instead;
otherwise:
if the blindturns of the player is less than 15:
now the blindturns of the player is the blindturns of the player plus 1;
say “It’s not a good idea to go blundering about in the dark, you could trip over something and have a nasty fall.”;
otherwise:
say “Whilst blundering about in the darkness (an activity which can only be described as [’]not a good idea[’]), you trip over something and crash to the floor, smashing your head on something very hard on the way. So hard in fact, you are knocked unconscious and fall into a coma… from which, you do not awaken.”;
end the story saying “You have died. Bad Ending(Nasty Fall)” instead.
After going when the room gone from is not naturallylit: [honestly this should be an “after going”]
if the room gone from does not enclose a lit thing:
now the room gone from is dark;
continue the action; [otherwise this blocks the “report going” rule]
otherwise:
now the room gone from is not dark;
continue the action.
test first with “w/w/switch off lamp/l/showme Alcove”. [since we haven’t been to the alcove, it never got set to being lighted and it doesn’t show up when we look, and interrupts the loop too]
test tour with “w/w/n/s/w/e/switch off lamp/l/showme Alcove/n/switch off lamp/s/n/n/n/n”. [looking messages not great]
test uh-oh with “w/w/n/s/w/e/switch off lamp/l/w”. [the loop in the before going rule hits north and interrupts the going action before you can go west, which is bad][/code]
OK, one more thing. We have some annoying logic involving looping over directions to check if the room that way is light-filled (or lit, depending on the version); which winds up printing a bunch of different messages about where the light is coming from. We can avoid that completely by defining an adjective on directions that checks whether the room that way is light-filled:
Definition: A direction (called that way) is light-going if the room that way from the location is light-filled.
and then wrap that up with a list, like so:
[code]A room is usually dark.
Cave Mouth is a lighted room. Outer Cave is west of Cave Mouth. Central Cave is west of Outer Cave. Alcove is north of Central Cave. Inner Cave is west of Central Cave.
A lamp is a kind of device. A lamp is usually fixed in place. A lamp is usually switched on. A lamp is usually lit. [these just ensure that the lamps are all switched on and lit at the beginning of the game.] One lamp is in every room.
Use the serial comma [dammit].
The flashlight is a lamp. The flashlight is portable. The flashlight is switched off. The flashlight is not lit. The player carries the flashlight. [Otherwise we’d never be able to switch a lamp back on, because we couldn’t see it.]
Carry out switching off a lamp (called lantern): now the lantern is not lit.
Carry out switching on a lamp (called lantern): now the lantern is lit.
The player has a number called blindturns.
Definition: A room is light-enclosing if it encloses a lit thing.
Definition: A room is light-filled if it is lit or it is light-enclosing.
Definition: A room is truly dark if it is not light-filled.
Definition: A direction (called that way) is light-going if the room that way from the location is light-filled.
Rule for printing the description of a dark room: [OK, this one is confusing. The name of the activity is “printing the description of a dark room,” but it’s not actually for any room that has the property “dark”; it’s really a rule for looking in darkness. There isn’t any corresponding activity “printing the description of a lighted room” or anything like that. See Writing with Inform §18.22]
if an adjacent room is light-filled:
say “It is pitch dark, and you can’t see a thing… except for a faint light coming from the [list of light-going directions].”; [this prints “the west, east, and north”; if you want “the west, the east, and the north” you could write [the list of light-filled directions] but I like that less]
otherwise:
say “It is pitch dark, and you can’t see a thing.” instead. [you don’t actually need the “instead” here, since it’s an activity–running one “for” rule for an activity automatically preempts all other “for” rules for the activity]
Before going from a truly dark room when the room gone to is truly dark:
if an adjacent room is light-filled:
say “It is not wise to continue on in darkness. You can make out a faint light coming from the [list of light-going directions].” instead;
otherwise:
if the blindturns of the player is less than 15:
now the blindturns of the player is the blindturns of the player plus 1; [there’s also a shorthand phrase for this, “increment the blindturns of the player”]
say “It’s not a good idea to go blundering about in the dark, you could trip over something and have a nasty fall. (You’ve been doing this for [blindturns of the player] turns.)”;
otherwise:
say “Whilst blundering about in the darkness (an activity which can only be described as [’]not a good idea[’]), you trip over something and crash to the floor, smashing your head on something very hard on the way. So hard in fact, you are knocked unconscious and fall into a coma… from which, you do not awaken.”;
end the story saying “You have died. Bad Ending(Nasty Fall)” instead.[/code]
I hope this is, er, illuminating.
And finally, note that instead of the definitions of light-filled and truly dark, we could use Draconis’s definitions using the I6 routines:
Definition: a room is light-filled rather than darkness-filled if I6 routine "OffersLight" says so (it contains a light source).
Definition: a thing is light-filled rather than darkness-filled if I6 routine "OffersLight" says so (it contains a light source).
which would take into account light sources in closed containers and the like.