Leaving an enterable scenery container...

So you have a box. This box is an enterable scenery container. You can climb inside of it. You can do so by typing “get in box” or “get in the box”.

You cannot, however, leave the box by typing “get out of box” or “get out box”. You have to type “exit” or “out” which is hardly natural.

I want to say I saw this referenced somewhere already, but I can’t track it down again.

“Get” is obviously one of those commands that I don’t want to override and screw up for the rest of the game. But it seems to me like “get out of the box” should do the same thing (in reverse) as "get in the box.


Makes sense. The problem isn’t actually with “get out” which (unadorned) redirects to “exit.” The thing is that “exit,” unlike “enter,” doesn’t apply to an object, since presumably there’s only one thing you can exit at any given moment, the thing that you’re in.

We can take care of this by creating another action that applies to one thing and uses the “get out/exit” syntax, and then redirecting that to exiting, making sure that you’re actually exiting something you’re in.

[code]Transitive-exiting is an action applying to one thing.
Understand “get out of [something]” or “get out [something]” or “exit [something]” as transitive-exiting.

Check transitive-exiting:
if the noun does not enclose the player:
say “You’re not in [the noun].”;
stop the action;
otherwise if the player is not in the noun: [that is to say, the noun isn’t the thing they’re directly in; this handles situations where you’re in one thing which in turn is in another, and you try to get out of the outer one]
say “You’re not in a position to get out of [the noun].”;
stop the action.

Carry out transitive-exiting:
try exiting.

This doesn’t mess up “get,” either. [If you’re curious about my methods, the way I hit on this was to try “Understand 'get out of [something] as exiting” and have the compiler tell me “Exiting isn’t an action applying to a thing, dummy.” Not in quite so many words.]

In fact, you can even exploit the fact that “exit” can get redirected to “go out” when you aren’t in anything and there’s an outside exit, thus:

After deciding the scope of the player while transitive-exiting: place the location in scope.

That allows you to type “get out of the kitchen,” and if there’s a room outside from the kitchen, exiting the kitchen will take you there.

There may be problems I haven’t thought of, and this may be somewhat reinventing the wheel, but it should be a start.

I’m not sure if any of these things are in those player-convenience extensions Aaron’s been working on, but here’s my version, which is a little fancier:

[spoiler][code]Chapter - Exiting and Entering

Section - Transitive Exiting

Getting out of is an action applying to one thing. Understand “exit [something]” as getting out of.

Understand “out/off/down/up” as “[out]”. Understand “of/from” as “[from]”. Understand “[out]” and “[out] [from]” and “[from]” as “[out of]”.

Understand “exit [out of] [something]” as getting out of. Understand “get [out of] [something]” as getting out of. Understand “go [out of] [something]” as getting out of.

Check getting out of when the noun does not enclose the player:
say “You’re not [if the noun is a supporter]on[otherwise]in[end if] [the noun] right now.”

Check getting out of:
Let the outer enclosure be the noun;
while the outer enclosure encloses the player:
let the inner enclosure be the holder of the player;
If the inner enclosure is not the outer enclosure:
say “(First exiting [the inner enclosure])[command clarification break]”;
silently try exiting;
try exiting;
if the inner enclosure is the holder of the player:
stop the action;

Section - Going Outside

Check going nowhere when the noun is outside:
Try exiting instead.

Section - The Way Out

A room has an object called the way out.

Definition: A room is exitable if the way out of it is a direction.

Check exiting when the holder of the player is an exitable room:
Try going the way out of the location instead.

Check exiting when the holder of the player is a not exitable room:
If the number of viable directions is 1:
let the way out be a random viable direction;
say “(leaving to [the way out])[command clarification break]”;
try going the way out instead.

Section - The Way In

To decide whether (way - a direction) is a way in:
Let destination be the room to the way;
if destination is not a room, no;
decide on whether or not the way out of destination is the way from destination.

To decide what object is the way in:
Let the best choice be nothing;
Repeat with way running through directions:
if way is a way in:
if the best choice is a direction, decide on nothing;
otherwise now the best choice is way;
decide on the best choice.

Check going nowhere when the noun is inside and the way in is a direction:
Try going the way in instead.

Section - Intransitive Entering

for supplying a missing noun when entering (this is the enter the location rule):
Now the noun is the location.

The enter the location rule is listed after the find what to enter rule in the for supplying a missing noun rulebook.

Check entering the location:
Try going inside instead.

Check going nowhere when the noun is inside:
say “There’s no obvious way to go inside from here. [list the exits]” instead.

This segment does not include a definition of “viable,” but I’m not sure the definition I’m using in my WIP is correct in all cases, so I’d rather not include it.

Heh, I think that new users are confused by some of the error messages due to Graham’s particular brand of British politeness. I often wish I could change this:

… to this:

Edited to add: I am referring to myself as the idiot in the above, not any other users – new or otherwise. :slight_smile:

I do in fact think it would be very helpful if a message like that included something along the lines of “Sometimes this happens when ‘examing’ or ‘glass’ have not been defined, or when one of them has been misspelled.”

UPDATE: For instance:

You’d think the compiler would be able to keep track of which one wasn’t defined, though…

The compiler isn’t very good at understanding text that it has already failed to understand. :slight_smile: It doesn’t at this point know whether “examing”, “the”, or “glass” is the problem, or whether this is a correct action with a screwed-up verb or vice versa.

(Remember that action names don’t have to end in “ing” – that’s only a convention. For that matter it’s perfectly legitimate to write “Examining the glass is an action applying to nothing.” The compiler doesn’t know that’s not what you intended to do.)

It could go through and try to recognize individual words, but that has its own barrel of possible screwups, starting with recognizing “the”, “on”, or “in” inappropriately.