[I7] Determining if a room is lit up or not without player

This should be simple, at least if feels like it should be, but all attempts so far have failed me.

Is there a way to determine if a room has light or not, when the player is not in it?

To clarify, this is what I understand about darkness so far:

  • For a dark room “room is dark” is always true even if player is in it carrying a light source.

  • “If player is in darkness” can be used to determine if player can see, whatever the source of light is, taking into account light sources within closed/transparent containers etc.

  • “If Spooky Room is in darkness”, however does not seem to work that way.

But that is the sort of thing I would like to test for: Is room x lit by any means or not, regardless of weather player is in it or not.

I could probably solve it in some more convoluted way by checking if my light sources are in the room or not and so on, but since the “in darkness” rule already seems to do some complex checking of light sources in containers and whatnot I thought I could tap into that somehow…but no go so far.

A simple example where this would be useful is:
“On the hill you see a dark, creepy hut.”
vs
“On the hill you see a little hut, its windows ablaze with cheery light.” if there is any sort of viable light source in the hut.

Regards
Savaric

The full lighting calculations are run only for the current location every turn.

To get at this directly, you could try:

To decide if (T - object) offers light: (- OffersLight({T}) -).

However, I haven’t given that more than a cursory test. It might not work in all circumstances.

You could also take a simpler approach: “if a lit thing is in the Hut…” That won’t do all the container work, but maybe you don’t need it.

Thanks, you’re probably right that I don’t need the container work in practice. It’s good to know I’m not missing something blatantly obvious though.

I was also considering some variant where you sneakily move the player to the room in question, test for “in darkness” and then move him back to where he was again. Not sure if that would work though, it depends on when the light calculation is actually made I suppose.

Example 81 describes how to do this. Unfortunately, if you have a backdrop that provides light, you need to handle it specially; other than that it works flawlessly.

Interesting, thanks for pointing that out. I had managed to miss that despite looking for examples on light and darkness.

And if we combine that example with my idea of moving the player…I think we solve the backdrop problem also, like so
(testing “in darkness” didn’t seem to work, but “can see a lit thing” does.):

Definition: a room (called the target room) is lit up: if the target room is lighted: yes; let l be location; move the player to the target room, without printing a room description; if the player can see a lit thing: move player to l, without printing a room description; yes; move player to l, without printing a room description; no;

(I just did a quick test, and it seems to work as expected.)