How would I modify Approaches to duplicate the “go to x” command as used in Nightfall?
I didn’t use “Approaches” in Nightfall. In case it’s any help here’s the relevant Chapter of Nightfall’s code, which you’re welcome to borrow and/or adapt.
I’ve attempted to remove bits that are purely specific to Nightfall, and to add comments pointing out other semi-Nightfall specific code that you’d need to remove or adapt.
Chapter 8 - Travelling by name
A room can be blocked or unblocked. A room is usually unblocked.
[ Some properties for optimizing route finding ]
A room has a direction called inboard. The inboard of a room is usually inside.
A room has a direction called outboard. The outboard of a room is usually inside.
Instead of going outside when the outboard of the location is not inside (this is the use outboard to go out rule):
let way be the outboard of the location;
try going way.
The use outboard to go out rule is listed first in the instead rules.
Gating relates various rooms to various rooms.
The verb to be a gateway to implies the gating relation.
Travelling to is an action applying to one visible thing.
Understand "go to [any room]" as travelling to.
Understand "go to [any known thing]" as travelling to.
Understand "find [any room]" as travelling to.
Understand "find [any known thing]" as travelling to.
Rule for printing a parser error when parser error is noun did not make sense in that context and (the player's command includes "go" or the player's command includes "find"):
say "You haven't come across any such thing."
[ Note that previously the game says a thing can be distant or near ]
[ Note that no-time is defined in my Variable Time Control extension - if you're not using that you'll need to remove all references to no-time ]
[ Note that the Noplace location is also specific to Nightfall]
Before travelling to when the noun is not a room:
if the noun is distant then
say "[no-time][The noun] [is-are] too far away." instead;
if the noun is carried then
say "[no-time]You are carrying [the noun]." instead;
if the noun is worn then
say "[no-time]You are wearing [the noun]." instead;
if the noun is visible then
say "[no-time][The noun] [is-are] right here." instead;
if the noun is a backdrop then
say "[no-time][The noun] [is-are] in more than one place; you'll have to be more specific." instead;
if the noun is unknown then
say "[no-time]You haven't come across any such thing." instead;
if the noun is a building and the entry direction of the noun is not outside begin;
let way be the entry direction of the noun;
let dest be the room way from the location of the noun;
otherwise;
let dest be the location of the noun;
end if;
change the noun to dest; [ now noun is dest ]
if the dest is Noplace then say "[no-time]You can't go there." instead;
if the dest is a room then say "(going to [the dest])[command clarification break]".
Check travelling to when the noun is the location:
take no time;
say "You are already there." instead.
Check travelling to when the noun is the travel destination:
say "[bracket]To continue an existing journey you can use the command CONTINUE or just C[close bracket][command clarification break]"
Carry out travelling to:
change the travel destination to the noun;
try continuing the journey.
The travel destination is a room that varies. The travel destination is Noplace.
Continuing the journey is an action applying to nothing.
Understand "c" or "continue" as continuing the journey.
[
continued-before is a truth state that varies.
continued-before is false.
Before continuing the journey when continued-before is false:
say "[bracket]Please wait - the first routefinding calculation can be quite slow, but it should be much faster after that.[close bracket][command clarification break]";
change continued-before to true.
]
Check continuing the journey when the travel destination is Noplace:
take no time;
say "You aren't going anywhere in particular right now." instead.
Check continuing the journey when the travel destination is the location:
take no time;
say "You are already at your destination." instead.
Check continuing the journey when the location is not passable:
say "[no-time]It looks like you'll have to go back and find another route." instead.
Carry out continuing the journey:
Let way be nothing;
if the outboard of the location is not inside begin;
if the location is a gateway to the travel destination begin;
if the inboard of the location is not inside then
change way to the inboard of the location;
otherwise;
change way to the outboard of the location;
end if;
end if;
if way is nothing begin;
if pathfinding-used is false, say "(please wait...)";
change pathfinding-used to true;
let way be the best route from the location to the travel destination through passable rooms, using even locked doors;
end if;
if way is nothing and (the location is blocked or the travel destination is blocked) then let way be the best route from the location to the travel destination, using even locked doors;
if way is nothing begin;
say "[no-time]You can't get there right now.";
rule fails;
end if;
say "(going [way])[command clarification break]";
try going way.
pathfinding-used is a truth state that varies.
pathfinding-used is false.
Report continuing the journey when the location is the travel destination:
say "You have arrived at your destination."
Does the player mean travelling to a room: it is likely.
Does the player mean travelling to the location: it is very unlikely.
Does the player mean travelling to something unknown: it is unlikely.
Rule for printing a parser error when parser error is noun did not make sense in that context and the player's command includes "[find]":
say "You don't know how to get there." instead.
Understand "find" or "go to" as "[find]".
[ The following definition is specific to Nightfall: you'll need to adjust it for your own game]
Definition: a room is passable:
if it is unblocked, decide yes;
if it is Church Street Bus Stop and the player has the bottle of booze, decide yes;
decide no.
Hopefully that may get you started. But note the above code uses the now deprecated “change x to y” phrase; you’ll probably want to change each of those to “now x is y” to be sure of compatibility with future releases of Inform.
Thanks. I had figured you rolled your own, but wasn’t expecting you to respond so quick.