Player being able to go through open and unlocked door on condition

I have two rooms: Kitchen and Living Room, with Kitchen being north of Living Room. Between them is an archway. Kitchen is supposed to be too dark to enter without a lit candle, so player needs to be in possesion of a lit candle in order to go through the Archway. I have something like this:

CODE:
Kitchen is a room.
Archway is a door. Archway is north of the Living Room and south of the Kitchen. Archway is scenery.
Instead of opening Archway when the candle is not lit:
say “It’s too dark to see anything. You need a source of light.”
END OF CODE

This does the trick. However, it produces this result:
(When player doesn’t have a lit candle in possesion)

n
(first opening Archway)
It’s too dark to see anything. You need a source of light.

(When player does have a lit candle in possesion)

n
(first opening Archway)

Kitchen

How can I hide the message (first opening Archway) in both cases?

Do you want the player to have to open the archway, rather than just go through it? You could add into your code:

Archway is open. Archway is not openable.

(The second bit will stop the player from closing it.)

Then replace your “instead of opening Archway” with “instead of going north from Living Room”.

4 Likes

Here’s a literal-minded answer:

Before going through the Archway when the Archway is closed:
	try silently opening the Archway.

Since it’s the object and not the door that’s causing problems for the player, you could skip the door thing altogether with something like

Check going north from the Living Room when the player is not carrying the lit candle:
	say "It's too dark to see anything. You need more light." instead.

You can “check” the action before permitting it based on criteria of your choosing (like carrying a lit candle).

1 Like

I make my own doors because I don’t like all the default behavior of the built-in Inform doors. I just make an object, give it a door name and description, but don’t say “It is a door.”

Then I just put goable/ungoable properties on them and use check/instead of rules about going from one room to another. I find it’s much easier to control them if you use fake doors.

2 Likes

It sounds like the Archway might better be just a backdrop in the Kitchen and the Living Room.

Basically, the reason to have an actual door is because there’s something game-mechanically interesting about it being open vs. closed or locked vs. unlocked.

3 Likes

Not entirely- it also allows (without extra authorial work) the typing of things like ‘Enter archway’ to be automatically handled…

2 Likes

I’m seconding jrb’s system.

The Kitchen is a room.
An archway is a door. It is north of the Living Room and south of the Kitchen. It is scenery.
Instead of going through the archway when the candle is not lit:…

Or if you want this to be a general system:

The Kitchen is dark.
Instead of going to a dark room when the candle is not lit:

That’s handy, but it’s also the easiest part to replicate. If you don’t need open/closed or locked/unlocked, you can handle ENTER ARCHWAY with a one-liner: “Instead of entering the archway: try going north.”

2 Likes

Only quite that simple if it’s a one-way door. But still true that it’s not too hard to handle passage in both directions.

But then you also have to handle GO ARCHWAY… And there’s also the adjacency relation… And route-finding… And the handy fact that rooms both front and back enclose a door but not a backdrop… And the fact that doors are shown on the map in the Index… :slight_smile: (Although many works won’t need any of these useful characteristics of ‘true doors’ either)

I like the idea of your unruly doors- like naughty puppies! What do they get up to? :wink:

Also the entering action!

If the rooms are already adjacent in the normal way, this is covered.

That’s true; you need two scenery objects or a backdrop to handle both sides.

If you are worried about whether a room encloses a specific “door”, you are paying way too much attention for the simple solution. I use these things as fire-and-forget.

Duh! True!

Duh again! Sorry, of course, that’s also true. Although you do lose the ability to specify whether routes use doors or not.

OK, probably! But I am interested- from your experience in what kind of situations is using Inform’s built-in door kind not the simple solution?

I do in fact use standard Inform doors most of the time.

I only avoid them when some of the built-in behavior gets in my way. Mostly cases where the doorway has to move or change its destination.

I’m standard doors people too. They haven’t given me a lot of trouble!

I’m not really good at this, FWIW