Checking for a door

I can’t seem to find the right syntax to check for a door in a certain direction.

If you take the place-in- scope example from 17.27 of the manual:

After deciding the scope of the player: repeat with the way running through directions: let first step be the room the way from the location; if the first step is a room: place the first step in scope; let second step be the room the way from the first step; if the second step is a room, place the second step in scope;
The above will work regardless of whether a door (open or closed) is in that direction. How do you check for a door first?

Thanks in advance.

let D be the door the way from the location;

Zarf… So what’s the correct way, in the repeat loop up above, to test if there’s a door in that direction. Basically, I’m trying to not put anything in scope if there’s a door in the way.

And given the assignment statement of yours, if there is no door in any direction, what default value will D hold in that case? Nil? Nothing? 0?

Repeat with the way running through directions: let D be the door way from the location.

Put your other code inside the repeat. If D is nothing, then there is no door in that direction.

Oh, sorry. “if D is not nothing…” is what you want to test.

Ah, that’s what I was looking for. Wasn’t sure what the default was. Nothing it is. Thanks, guys.

While we’re talking about scope rules…

If, as in the code above, I place something in another room specifically in scope, does it remain that way regardless of where the player goes? In other words, does the engine consider it in scope until explicitly taken out of scope again? Or on every game turn is the scope of all objects re-figured automatically?

EDIT: Never mind. Of course it’s figured each time. That’s what the “After deciding the scope of the player” rule is all about.

One thing to be careful of with this: don’t use the adjective “visible” in a scope rule. I may have made this mistake. :laughing:

You can also check for “the room-or-door the way from location.” This will return, well, the room or the door that is the way from the location (or nothing if there’s neither). Then you ought to be able to simply check whether that’s a room – if it’s either a door or nothing that check will fail.

See section 6.14 of the documentation, which does say ‘The phrase is used mainly by the Standard Rules, for technical reasons, and usually it’s better to use “room … from …” or “door … from …” instead.’ But I don’t see why the Standard Rules should get to have all the fun! Unless there’s some technical reason why it’s really bad to use it.

Yeah, I think I ran into a little bit of that myself. I supposed the visible attribute might be manipulated by more than one rule…

Thanks all!