the best route from... to... without using doors

Everything works fine, except one situation… I’m trying to have a dog follow the player whenever she’s outdoors. However, I don’t want the dog to enter areas that are separated from other outdoor rooms by a door. So I’m leaving out the “using doors” part of the phrase.
Now, if the player enters a room (through a door), Inform7 returns the following in-game: You must supply a noun. instead of The dog arrives from the north., which is rendered when changing rooms without a door between them.

I could do without the meta-comment. What am I missing? :slight_smile:

Basic code to illustrate.

The garden is a room. "This is the garden." The dog is a male animal in the garden.
The enclosure is a room. "This is the enclosure."
The fence is a door. The fence is south of the garden and north of the enclosure. The fence is closed, openable and unlocked.

Outdoors is a region. The enclosure, the garden are in Outdoors.

Every turn when the player is in Outdoors:
	if the location of the dog is not the location of the player:
		let the way be the best route from the location of the dog to the location of the player;
		try the dog going the way;
	otherwise:
		say "The dog lets out a short bark in excitement."

I think you want to say something like

unless the way is nothing: try the dog going the way;

with proper indentation. As it is, when you go through the door, the best route is nothing (there’s no route), so your code has you trying the dog going nothing, which is what gets you the error. (I think; haven’t tested it.)

I was hoping that the “actions” debugging command would show what the dog was actually trying, but it didn’t. So I had to resort to “print” statments, which confirmed my suspicion:

Every turn when the player is in Outdoors: if the location of the dog is not the location of the player: let the way be the best route from the location of the dog to the location of the player; showme the way; try the dog going the way; otherwise: say "The dog lets out a short bark in excitement."

This reveals:

There’s no way for the dog to get to you without using doors, so the best route is nothing. If you “try the dog going nothing,” you get an error!

Probably what you want is to make sure there’s a way between every outside location with no doors. But just in case there isn’t, you can add this:

Every turn when the player is in Outdoors: if the location of the dog is not the location of the player: let the way be the best route from the location of the dog to the location of the player; if the way is a direction, try the dog going the way; otherwise: say "The dog lets out a short bark in excitement."

I suppose this might be considered a bug, because failed actions by NPCs are supposed to be reported by the “unsuccessful attempt” rules, not the regular check rules. But it appears that Graham never expected anyone to use “try” to go nowhere.

Thanks both, it seems an extra check will clear things up.

I’m still fairly new to this, but I expected “try” would yield a correct result, given its inherent meaning, after all.

Also, I don’t quite see the point of the phrase addition “using doors” (or rather, its omission) as it results in an error once the condition isn’t always fulfilled?
I.e. I thought that “using doors” (or not) was the check in itself as to whether the action could succeed.

I think it makes sense if you consider all the possibilities. Suppose you added this:

The pasture is southwest of the garden and northwest of the enclosure.

Now the dog can go around the fence, and it does. If you had said “using doors,” the dog would arrive 1 turn sooner by way of the fence.

You’ll note that the “best route” phrase never results in an error by itself - it’s a phrase that returns an object, not a phrase that returns a direction. I don’t know about you, but I wouldn’t want the phrase to lie to me when there really was no route from A to B. So the “nothing” object is an allowable value for it to return. The problem is when you try to use the “nothing” object as a noun.

Yup, you’re right. I was too quick to respond. :slight_smile:

Thanks again!