Beginners visibility rule question [i7]

I’d like for an object to “glow in the dark” – for it to be visible to the player even in dark rooms, without actually providing enough light to see by.

Ignoring the issue of printing the room descriptions, I can’t seem to get the simplest visibility rule working:

Visibility rule when examining the gem: there is sufficient light.

If I then examine the gem in a dark room, I get the standard response “You can’t see any such thing.” I imagine I’m just totally misunderstanding how visibility rules work, but can’t seem to find anything that answers my questions in the docs/examples. :slight_smile:

(Even if there is a much simpler way to accomplish this goal, I’d also like to understand how visibility rules work.)

Section 12.19 of the oft-maligned documentation seems helpful here:

So you aren’t even reaching the visibility rules in this case (unless you’re holding the gem); when in darkness, anything that you don’t enclose isn’t in scope, so the parser treats the gem as something that isn’t in the room with you (or isn’t even implemented), and doesn’t check for light. To change this, we need to manually place the gem in scope, as in section 17.27 of the documentation. Maybe something like this (untested):

After deciding the scope of the player when the location encloses the gem: place the gem in scope.

(This may not produce the right results if the gem is in an opaque container in the location – I’m not sure how to handle that, you might have to write it in by hand. And I may have got the phrasing of the if-clause off anyway.)

Once this is in, you need your visibility rule anyway (it looks like), to allow examining to succeed even though you’re in darkness.

Thanks, that did it! The generalised code I came up with is:

[code]An object is either glowing or nonradiant. An object is usually nonradiant.

After deciding the scope of the player while in darkness:
Repeat with glower running through glowing objects in location:
Place glower in scope.

Visibility rule when examining a glowing object: there is sufficient light.

After printing the description of a dark room:
Repeat with glower running through glowing objects in location:
Say “There is a glowing [glower] here.”[/code]
The bit for printing descriptions is a bit ugly, but everything seems to work fine even when opaque containers are involved.

Unfortunately, I think what’s going on is that you’re missing out on anything in any container or on any supporter. If you try this as your test scenario with that code:

Kitchen is a dark room. A counter is in kitchen. A gem is on the counter. The gem is glowing.

the gem doesn’t show up in the room description. The issue is that “in location” only applies to things that are in the location and nothing else; the gem isn’t in the location because it’s on the counter. We can catch this by changing “in location” to “enclosed by the location,” but then we get the things that are in opaque containers too, as we can see by adding this:

A refrigerator is an opaque closed container in the kitchen. An egg is in the refrigerator. The egg is glowing.

And then if the player is in an enterable closed opaque container, things get even more complicated. I’m not sure if there’s a simple way to do this, exploiting the rules that I7 already has for determining visibility (since what you want is that the glowing things should show up if the player could see them, were the room lit), or if you have to write a bunch of complicated special cases, or if you can just copy something from the standard rules, changing everything you need to.