Quick Question--Having Difficulty with Staircases

Reading the code for a staircase, it seems simple enough–just treat it like a door. But I must be overlooking something here because I can’t seem to interact with the staircase at all. I imagine that (as usual) it’s just something to do with the way I’m phrasing things, but I’ve been playing around with this and don’t seem to be having much luck.

It sounds like, in theory, this code should be sufficient:

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

The Courtroom Staircase is an undescribed open staircase. It is up from the Courthouse–Foyer and down from the Courthouse–2nd Floor Foyer. Understand “stairs”,“stair”,“staircase”, and “staircases” as the Courtroom Staircase.[/code]

Ideally, the player will be in a foyer and in the description of the foyer, it will explicitly tell them there is a staircase they can interact with. From there, they would say at minimum “go up stairs” or “go down stairs” depending what floor they’re on (I would add “understand” rules to further expand input possibilities, but at the very least those two). However, I can’t “go up” the stairs, I can’t “enter” the stairs, I can’t seem to move any direction that would get me to the 2nd Floor Foyer.

I guess now that I think about it, I probably could just have the two foyers directly connected and say in the description that the player took the stairs. But surely, I shouldn’t have to do that and I would like the player to be able to say “go up the stairs” or something to that effect. I’m thinking now that me saying that the stairs are “up” might be an issue as I suppose they technically aren’t up from a room, they just extend up.

I’m confusing myself more and more trying to figure this out, so any help you guys could offer would be great :slight_smile:

I think your problem with “enter staircase” is that you have the staircase as “undescribed.” If you take that out “enter staircase” works. I’m not sure exactly why this is, but as a rule you shouldn’t make things undescribed; make them scenery instead. (See some discussion of this in section 3.24 of the documentation.)

That won’t get you “go up the stairs” and “go down the stairs,” though. To do that, you have to do something that lets the game understand a command with a direction and a noun. I’d try defining a new action:

[spoiler][code]A staircase is a kind of door . A staircase is usually open. A staircase is seldom openable.

The Courtroom Staircase is an open scenery staircase. It is up from the Courthouse–Foyer and down from the Courthouse–2nd Floor Foyer. Understand “stairs”,“stair”,“staircase”, and “staircases” as the Courtroom Staircase.

A key is in Courthouse–Foyer.

Stairwalking it through is an action applying to one visible thing and one thing. Understand “go [something] through [something]” or “go [something] [something]” as stairwalking it through. [The “it” tells Inform where the first noun goes, so calling the action “stairwalking it through” allows us to say “stairwalking up through the courtroom staircase” and the like elsewhere in the code.]

Check stairwalking it through when the second noun is not a door:
say “You cannot go through [the second noun].” instead.

Check stairwalking it through when the noun is not a direction:
say “You can only go in valid directions.” instead.

Check stairwalking it through when the second noun is a door and the noun is a direction:
if the second noun is not the door the noun of the location: [that second clause is rather funny-sounding, but since the noun will be a direction, it boils down to something like “the staircase is not the door east of the location” – that is to say, the door you’re trying to go through isn’t the direction you’re trying to go]
say “Going [noun] won’t take you to [the second noun].” instead.

Carry out stairwalking it through: [if everything works, you tried going the right direction to a door, so go into the door]
try entering the second noun.
[/code][/spoiler]

This doesn’t get you “go upstairs” and “go downstairs,” though, which are more natural. (Nor does it get you “walk up the stairs” or “up the stairs.”) To do that I might define “upstairs” and “downstairs” as directions, block going in those directions unless there’s a staircase in the location, and redirect them to going up/down if there is. (“The location” is the room the player’s in, by the way.)

An aside: You mentioned saying in the description that the player went up the stairs. In general, you should never include a narration of an action as part of the room description. If the player goes up and then types “look,” you don’t want the room description to say that she went up the stairs again. The best way to insert a description of how the player got from room A to room B is to use a rule like “After going up from Courthouse–Foyer, say…” That only prints the relevant text when the player goes up from Courthouse–Foyer, not any other time.

EDITED TO ADD: Someone may have written an extension that takes care of some of this stuff, also.

Yeah, I wouldn’t go so far as to define a staircase as an open door. I would just make the staircase a scenery item in the locations where it existed, then make up/down exits in those places. Staircases are like light switches - people use them in real life, but to define them in IF is a little too detailed.

Unless, of course, you want something to occur on your staircase, maybe then the staircase should be a room.

Why not just declare synonyms of the existing directions? Understand "upstairs" as up. Understand "downstairs" as down. Sure, the parser won’t refuse “go upstairs” when under a treehouse, but that doesn’t seem like a big problem. If it bothers you, you could append “when a staircase is in the location” to each of those synonym-defining statements.

Huh? This doesn’t make sense to me. What is a staircase in IF besides a vertically-oriented, open-and-not-openable door? Staircases and doorways are both things that connect two rooms, appear in each room, are open-and-not-openable, and can be travelled through in lieu of specifying a direction. How does breaking a staircase into two separate objects, which would require even more special coding to allow the player to traverse it explicitly, improve the simplicity of code or the world model, or make the player’s life easier?

I mean, a staircase is the very second example of a door presented in the documentation (after a grating, which both hearkens back to the first door in the IF corpus and was explicitly a rewrite of the aforementioned staircase). Why don’t you believe it’s not a standard IF object in any but the largest, staircase-as-room implementations?

ChrisC has an excellent point about “upstairs” and “downstairs.” In general, it probably isn’t a problem when the game understands a command that it shouldn’t; it’s when it doesn’t understand a command that it should that players get angry.

My original code doesn’t work well when there are two staircases in the same room; if you type “go up stairs” it’ll ask you “Which do you mean, The Courtroom Staircase or The Basement Staircase?”, which is very annoying since it’s clearly the one that goes up. Adding this seems to work:

[code]Leading relates a door (called passageway) to a direction (called the way) when the passageway is the door the way from the location. The verb to lead to (he leads to) implies the leading relation.

Does the player mean stairwalking when the second noun leads to the noun: it is likely.
[/code]

This may be the first time I’ve ever got Does The Player Mean rules to do exactly what I wanted.

Oh, I also have this:

 Understand "stairs","stair","staircase", and "staircases" as a staircase.

If you have more than one staircase, you’ll want this so the player can always use these words to refer to whatever staircase is around.

For the record, here’s all my code currently:

[spoiler][code]A staircase is a kind of door . A staircase is usually open. A staircase is seldom openable.

The Courtroom Staircase is an open scenery staircase. It is up from the Courthouse–Foyer and down from the Courthouse–2nd Floor Foyer. Understand “stairs”,“stair”,“staircase”, and “staircases” as a staircase.
The Basement is a room.
The Basement Staircase is a scenery staircase. It is down from Courthouse–Foyer and up from the Basement.

A key is in Courthouse–Foyer.

Leading relates a door (called passageway) to a direction (called the way) when the passageway is the door the way from the location. The verb to lead to (he leads to) implies the leading relation.

Stairwalking it through is an action applying to one visible thing and one thing. Understand “go [something] through [something]” or “go [something] [something]” as stairwalking it through. [The “it” tells Inform where the first noun goes, so calling the action “stairwalking it through” allows us to say “stairwalking up through the courtroom staircase” and the like elsewhere in the code.]

Check stairwalking it through when the second noun is not a door:
say “You cannot go through [the second noun].” instead.

Check stairwalking it through when the noun is not a direction:
say “You can only go in valid directions.” instead.

Check stairwalking it through when the second noun is a door and the noun is a direction:
if the second noun is not the door the noun of the location: [that second clause is rather funny-sounding, but since the noun will be a direction, it boils down to something like “the staircase is not the door east of the location” – that is to say, the door you’re trying to go through isn’t the direction you’re trying to go]
say “Going [noun] won’t take you to [the second noun].” instead.

Carry out stairwalking it through: [if everything works, you tried going the right direction to a door, so go into the door]
try entering the second noun.

Does the player mean stairwalking when the second noun leads to the noun: it is likely.

test me with “go up key/go key through basement stairs/ go north through basement stairs/go up stairs/go down stairs/go down stairs”.[/code][/spoiler]