About making objects "glow" just a little bit in darkness

Hello,

I am trying to write a routine that makes objects “glow” a little bit in darkness. Here’s what I have so far. It will allow the player to examine “glowing” objects which give off enough light to be visible, but not enough to illuminate the whole location. Containers aren’t implemented yet. If the orb is put in an open box, for example, it will not show up in the dark.

Code:

"What Gloweth Must Be Seen" by Steve Westwood

Part 1 - Set-Up

Rule for printing the description of a dark room:
	say "Your eyes can barely make anything out." instead. 
	
After printing the description of a dark room:
	repeat with glorb running through things in location:
		if glorb is a glowing thing:
			place glorb in scope;
			if the initial appearance of glorb is not "":
				say "[line break][initial appearance of glorb][paragraph break]"	
			
After deciding the scope of the player while in darkness:
	repeat with glorb running through things in location:
		if glorb is a glowing thing, place glorb in scope;
		
Visibility rule when examining something:
	if the location is a dark room:
		if the thing is a glowing thing, there is sufficient light;
	
Part 2 - Rooms and Objects

The Lit Place is a room with printed name "The Lit Room". The description of the Lit Place is "Sunlight filters through the windows that make up the walls and reflects off the white panelling of the frames."

The player is in the Lit Place.

Before going to the Lit Place when the location of the orb is the Lit Place:
	say "You think about being blinded again, and decide not to go into the Lit Room after all.";

After going to the Lit Place when the location of the orb is the Lit Place:	
	if the orb is carried by the player:
		now the dark place is lit;
		move the orb to the Lit Place;		
		say "As you enter the room while carrying the orb, a blinding flash sears your retina. Instinctively, you close your eyes and cover them with your hands, dropping the orb. You stumble back through the door to the east.";
		try the player going east;

The Dark Place is a dark room with printed name "The Dark Room". The description of the Dark Place is "There are no windows in this room. The walls are cedar, giving the room a very rustic atmosphere. Low benches line the walls.[if the location of the orb is the Lit Room][paragraph break]Light filters in from the Lit Room, illuminating this room very well.[end if]". The Dark Place is east of the Lit Place.

The benches are a supporter in the Dark Place. The benches are enterable. The benches are plural-named.

Understand "bench" as the benches.

A thing can be glowing or plain. A thing is usually plain. 

The orb is a glowing thing in the Dark Place. "There is an orb here, glowing gently." The description of the orb is "This orb is made out of crystal and glows in the dim light.".

Understand "glowing" and "crystal" as the orb.

Any suggestions on how to accomodate containers? So that if a glowing orb is in a small glass case which is itself in an open cardboard box, that the case and the box can be seen as well as the orb? But that if the case with the orb is removed from the box, the box is no longer put into scope?

Thanks.

Seems like you might need to re-define “dark room” to accomidate only the kinds of actions you want to allow. Or to specifially tag certain objects back in scope.

Sorry for not writing about this in ages. Life has been crazy.

Thanks for your suggestions tggdan3. In situations which call for it, I will tag specific objects back in scope. If I have only one object in a game that needs this feature, for example, I may do just that. However, I also believe I have found a way to do this more dynamically.

Here is at least a partial solution I’ve worked out to share with you all:

[code]“What Gloweth Must Be Seen” by Steve Westwood

Part 1 - Set-Up

Darkroomobjects is a number variable.

Rule for printing the description of a dark room:
say “Your eyes can barely make anything out.” instead.

After printing the description of a dark room:
now darkroomobjects is 0;
repeat with glorb running through things in location
begin;
if glorb is a glowing thing or glorb encloses a glowing thing and (glorb is transparent or glorb is open)
begin;
place glorb in scope;
now glorb is marked for listing;
now darkroomobjects is 1;
otherwise;
now glorb is not marked for listing;
end if;
end repeat;
if darkroomobjects > 0
begin;
say “[line break]You do see [run paragraph on]”;
list the contents of the location, as a sentence,
tersely, listing marked items only, including contents and giving brief inventory information;
say “.”;
end if.

After deciding the scope of the player while in darkness:
repeat with glorb running through things in location
begin;
if glorb is a glowing thing or glorb encloses a glowing thing and (glorb is transparent or glorb is open)
begin;
place glorb in scope;
end if;
end repeat.

Visibility rule when examining something:
if the location is a dark room:
if the thing is a glowing thing, there is sufficient light;

Part 2 - Rooms and Objects

The Lit Place is a room with printed name “The Lit Room”. The description of the Lit Place is “Sunlight filters through the windows that make up the walls and reflects off the white panelling of the frames.”

The player is in the Lit Place.

Before going to the Lit Place when the location of the orb is the Lit Place:
say “You think about being blinded again, and decide not to go into the Lit Room after all.”;

After going to the Lit Place when the location of the orb is the Lit Place:
if the orb is carried by the player:
now the dark place is lit;
move the orb to the Lit Place;
say “As you enter the room while carrying the orb, a blinding flash sears your retina. Instinctively, you close your eyes and cover them with your hands, dropping the orb. You stumble back through the door to the east.”;
try the player going east;

The Dark Place is a dark room with printed name “The Dark Room”. The description of the Dark Place is “There are no windows in this room. The walls are cedar, giving the room a very rustic atmosphere. Low benches line the walls.[if the location of the orb is the Lit Room][paragraph break]Light filters in from the Lit Room, illuminating this room very well.[end if]”. The Dark Place is east of the Lit Place.

The benches are a supporter in the Dark Place. The benches are enterable. The benches are plural-named.

Understand “bench” as the benches.

A thing can be glowing or plain. A thing is usually plain.

The box is a container in the Dark Place. The box is openable. “Dooby”

The basket is a container in the box.

The orb is a glowing thing contained in the basket. “There is an orb here, glowing gently.” The description of the orb is “This orb is made out of crystal and glows in the dim light.”.

Understand “glowing” and “crystal” as the orb.[/code]
Any comments are appreciated, especially thoughts on how to make this more elegant and efficient. :wink: