Entering when a noun is not supplied

I have a passageway room which has two doors leading to other rooms. Entering either by name works fine, and simply typing “enter” returns “You must supply a noun.” I have two questions:

  1. How can I change the “You must supply a noun” message, but only in the passageway room?

  2. Would it be possible to make one of the rooms enterable and exitable (by the player using “enter” and “exit” commands) without making a door between it and the passageway, or does a door have to be there for enter/exit to work? Obviously I would need to be able to specify which rooms this would apply to.

Many thanks for reading!

For changing the error message, you could try something like: Rule for supplying a missing noun while entering in the passageway: say "You must choose between the green and the red door." (But be warned that this is not really what the supplying a missing noun activity is for; and, of course, if at any time there is something else in the passageway that could be entered, your new message might become misleading.)

To allow the player to enter rooms, I came up with this:

[code]After deciding the scope of the player while entering:
repeat with chamber running through adjacent rooms:
place the chamber in scope.

Instead of entering a room:
repeat with D running through directions:
if the noun is the room D from the location, try going D.

[/code] It works for the simple case at least, but it’s certainly not thoroughly tested. Also, it won’t work if there is a door between the rooms (since then the rooms won’t be ”adjacent” by Inform’s standards).

If you want “ENTER” to let you go inside when it’s possible to go inside, you can direct “enter” to a new action when you’re in the right location, and redirect that new action to going inside:

[code]Plain entering is an action applying to nothing. Understand “enter” as plain entering when the room-or-door inside from the location is not nothing.

Instead of plain entering: try going inside.

Hut Exterior is a room. “You can go inside the hut. The path leads east.” Hut Interior is inside from Hut Exterior. The Path is a east of Hut Exterior. “The hut is west.”[/code]

You could change the “Understand” clause to “when the location is the passageway,” and change the direction in “Instead of plain entering:” to whatever you like. This lets plain old “enter” take you to a room, but doesn’t let the player say “enter [name of room]” the way Felix’s code does. And you don’t need a door to do it.

It’s a lot easier to convert “exit” to going a direction when you’re in a particular place; since exiting is an action that doesn’t require a noun, you can just redirect it:

Instead of exiting when the player is in the Hut Interior: try going outside.

(There’s a subtlety here – unless I’ve messed it up “when the player is in the Hut Interior” is true when the player is in the Hut Interior but not in anything else. If you wrote “Instead of exiting in the Hut Interior,” it would make it impossible to carry out the exiting action when you were inside an enterable container in the Hut Interior, which would be bad.)

There are a couple of extensions – Emily Short’s Modified Exit and Aaron Reed’s Small Kindnesses – which will tweak the “exit” action to make it more friendly for you in a way like this.

You could avoid Felix’s concern about other enterable things in the passageway by building a list of the things you can enter. And in fact, you can even rig this so it automatically enters you into the only enterable thing or door in the room, if there’s only one. (The standard rules have something that does this, called the “find what to enter rule,” but it doesn’t apply to doors which could be annoying if something enterable winds up next to your door.)

[code]Use American dialect and the serial comma.

The passageway is a room. The red door is a door. it is west of the passageway and east of the red room. The blue door is a door. It is east of the passageway and west of the blue room. The box is an enterable container in the blue room. The crate is an enterable container in the blue room. The green room is west of the red room.

For supplying a missing noun when entering:
let enterlist be a list of objects;
now enterlist is the list of enterable things in the location;
add the list of doors in the location to enterlist;
if the number of entries in enterlist is 1:
now the noun is entry 1 in enterlist;
say “([the noun])[command clarification break]”;
otherwise if the number of entries in enterlist is 0:
say “There’s nothing to enter here.”;
otherwise:
say “You must supply a noun; you can enter [enterlist with definite articles] here.”

Test me with “enter/enter red/w/enter/e/enter/enter blue/enter/take box/enter/enter blue/drop box/enter/take box/enter red/w/drop box/enter”.[/code]

Looking at the Standard Rules, I don’t think there’s anything else enterable I haven’t thought of, but there might be. This doesn’t mix well with the plain entering action I put above. (Apologies for the lowercase room names.)

Now, what you might want is something like a disambiguation, where “enter” pops up “What do you want to enter, the red door or the blue door?” and lets you respond with “red.” That strikes me as something that would take a lot of work.

I couldn’t resist building upon Matt’s and my previous code.

The following is meant to let you enter rooms, including rooms on the other side of a door, and to simulate a disambiguation question in the special case of entering something unspecified.
It’s only marginally tested, though.

After deciding the scope of the player while entering:
	repeat with chamber running through adjacent rooms:
		place the chamber in scope;
	repeat with entrance running through doors in the location:
		if the other side of the entrance is not nothing:
			place the other side of the entrance in scope, but not its contents.
			
Disambiguation needed is a truth state that varies.
Understand "[something]" as entering when disambiguation needed is true.
Before entering something: now disambiguation needed is false.

For supplying a missing noun when entering:
	let enterlist be a list of objects;
	now enterlist is the list of enterable things in the location;
	add the list of doors in the location to enterlist;
	add the list of adjacent rooms to enterlist;
	if the number of entries in enterlist is 1:
		now the noun is entry 1 in enterlist;
		say "([the noun])[command clarification break]";
	otherwise if the number of entries in enterlist is 0:
		say "There's nothing to enter here.";
	otherwise:
		let N be the number of entries in enterlist;
		say "Which do you mean";
		repeat with M running from 1 to (N - 1):
			say ", [the entry M of enterlist]";
		if N is greater than 2 and the serial comma option is active, say ",";
		say " or [the entry N of enterlist]?";
		now disambiguation needed is true.
		
Instead of entering a room:
	repeat with D running through directions:
		if the noun is the room D from the location, try going D;
	repeat with D running through doors in the location:
		if the noun is the other side of D from the location, try entering D.

Awesome! Thanks guys, I appreciate the effort.