Stairs with a door at top

How do you code stairs that leads up from a ground floor room,
through a closed/locked door,
to a first floor room?

I have tried a few options.

I can get the stairs working from the ground floor room up to the first floor room.

I can not get the the door in between the stairs and the rooms.

I have tried below but obviously it would not work.

woodshed is a room.
loft is a room.

A staircase is a kind of door. A staircase is usually open. A staircase is seldom openable.

A wooden door is a door. It is up from the stairs. It is south from the loft. 
The ladder is a staircase. It is up from the woodshed. It is down from the loft.

Right, I don’t think you can have a door next to another door - they need to be between rooms. I’d just make a single door object representing the stairs and the door - you can make the “stairs” closed and locked just like any regular door.


Mike’s proposal seems reasonable, but I’d add that you want to provide appropriate messaging to the player or it will seem as though the stairs themselves are locked, and not a door.


If you have a dramatic reason to allow the player to climb the stairs but stop them cold at the door, you can add a room between the door and the stairs like a landing or top of the staircase. If you desire so, with some rules work and clever descriptions you should be able to code for passing the door and the stairs in one seamless move in either direction without stopping at the landing when the door is open and/or unlocked.

If you have no need for such shenanigans @DeusIrae’s solution is easier to code and better.


The reason for this is that I want the player first to discover the key before he can enter. If he cannot find key those clues in the other room will stay hidden.

Looks like this should work:

A staircase is a kind of door. A staircase is usually open. A staircase is seldom openable. A staircase can be unlockable. A staircase can be lockable.
stairs-from-woodshed-up is staircase. It is above from the woodshed and below from the landing. The printed name of stairs-from-woodshed-up is "stairs leading up from the woodshed and down from the landing platform". Understand "stairs" as stairs-from-woodshed-up.
door-from-loft-to-landing is a door. It is north from the landing and south of the loft. The door-from-loft-to-landing is locked. The silver key unlocks the door-from-loft-to-landing. The printed name of door-from-loft-to-landing is "a door leading south to the loft and north to the landing platform". Understand "door" as door-from-loft-to-landing.
Instead of climbing the stairs-from-woodshed-up:
	try entering the noun.
The player carries the silver key.

I suppose you could implement a staircase as a supporter within a room instead of as a door. You could disallow interacting with the door unless the player is on the staircase.

Rough implementation:


Thanks will have a look as it might work better for what I want.

I came up with the following: It may not quite be what you need, but shows how things can be part of other things and how you can manipulate them. The example has a ‘door’ (which is actually an enterable container) that is part of a staircase kind (which is actually the door). You may be able to use some of the idea’s

The lab is a room. "A dreary laboratory"

A stairdoor is a kind of enterable container. A stairdoor is usually lockable and locked. A stairdoor is usually openable and closed.

A staircase is a kind of door.  It is always fixed in place. A stairdoor is part of every staircase. A staircase is always open. Understand "door" as stairdoor. The description of a stairdoor is "There is nothing noteworthy about [the item described]."

A staircase is always privately-named.

to say the blocker of  (S - a staircase):
	Let the blocker be the stairdoor;
	say "[a blocker]".
to say the initial appearance of (S - a staircase):
	Let the blocker be the stairdoor;
	Let step direction be direction of S from the location;
	if the step direction is not up and the step direction is not down:
		say "There [are] [a blocker] to [the step direction]. [The blocker] [are] [the state of the blocker][if the blocker is open]. Through [the blocker] you can see [a S][end if].";
		say "There [are] [an S] here which leads [step direction] to [a blocker].  [The blocker] [are] [the state of the blocker]."

The initial appearance of a staircase is "[the initial appearance of the item described]"

Instead of climbing a staircase (called the steps):
	try entering the steps.

Before pushing or pulling a stairdoor (called the barrier):
	Try opening the barrier instead.
Before entering a stairdoor (called the barrier):
	try going the direction of the holder of the barrier from the location instead.
Instead of doing anything except examining, opening, closing, locking or unlocking to a stairdoor:
	say "But [the current action] is not going to help.".
Does the player mean unlocking a stairdoor with a key: It is very likely.
Check going through a staircase:
	if the stairdoor (called the blocker) is locked:
		say "But [the blocker] is locked." instead;
	if the stairdoor (called the blocker) is closed:
		say "(Opening [the blocker] first)[paragraph break]";
		try silently opening the blocker;
After going through a staircase (called the steps):
	Let barrier be the stairdoor;
	Let up_down be some text;
	Let step direction be direction of the steps from (the other side of the steps from the location);
	If the step direction is not up and the step direction is not down:
		if the location is the front side of the steps:
			Let up_down be "down";
			Let up_down be "up";
	say "You climb [step direction][if up_down is not empty] [up_down][end if] [the steps] passing through [the barrier].";
	Continue the action.
A ladder is a staircase in the lab. The printed name of the ladder's stairdoor is "wooden door". Understand "wooden" as the ladder's stairdoor.

Understand "ladder" as the ladder when the ladder's stairdoor is open or the location is the front side of the ladder.

The description of the ladder's stairdoor is "A wooden door lies [the state of the ladder's stairdoor]."

A silver key is in the Lab. The matching key of the ladder's stairdoor is the silver key.

To say the state of (D - a container):
	if D is open:
		say "open";
		say "closed".

The ladder is up from the Lab.
The ladder is south from the Top Floor.

The Top Floor is a room. "The top floor." 

Test all with "U/Enter Ladder/Unlock door/U/x ladder/close door/x ladder/S/close door/x ladder"

Thanks, will have a look