Inform 6:How to extract direction, location from a Go order?

Part of my current project’s map is a lake.

I made a “Lake” class to describe the rooms which make up the lake. It has rules for drowning (or swimming to shore if there is one nearby).

I also made gave a “dock” attribute to the two actual docks in the map. These are not Lake rooms.

I’d like to limit the movement of the boat to Lake rooms, and to the docks.

Below is how I roughed it out:

Object lost_boat "A humble punt" north_shore with name 'punt' 'humble' 'boat', description "A shallow old punt made of weathered plywood. It looks in good repair.", before [; Go: if(parent(GODIR)==Lake) { print "You row the punt"; move self to direction; } else if(GODIR has dock) { print "You skillfully tie the punt to the dock."; move self to direction; } else { "Sorry. Unlike Michael, you can't row the boat ashore . . . only on the lake or up to a dock."; } ], has enterable container open static ;

Now, the problem is, how do I determine the room that lies in the desired direction?


Lake middlelake with description "middle of lake", n_to north_dock, s_to south_lake;

The player is in the boat and the boat is in middlelake. The player enters “GO NORTH”.

How do I extract “north dock” from that command?



I’m not sure how others would this, but this is how I would do it.

“Go” is definded in Grammar.h as:

Verb 'go' 'run' 'walk'
    *                                           -> VagueGo
    * noun=ADirection                           -> Go
    * noun                                      -> Enter
    * 'into'/'in'/'inside'/'through' noun       -> Enter;

So Go is read by the Room object, I wouldn’t be trying to read it from the boat object.
If you have to break out Go from Run/Walk I would do that. But I think players would
be more likely to just type north or south in the first place. Playtesting helps with this.

I think your Middle of the Lake Object should look like this:

Lake middlelake
with description "middle of lake",
n_to [;
    print "You skillfully tie the punt to the dock.^";
    return north_dock;
s_to [;
    print "You row the punt.^";
    return south_lake;
cant_go "Sorry. Unlike Michael, you can't row the boat ashore . . . only on the lake or up to a dock.";

Also, with a can’t go like that a player might try, Row To Dock or Row To Lake.

If you’re really worried about run/walk you can break those away: copy the GoSub from the Verblibm.h
renaming it to WalkSub or something that doesn’t conflict and putting something like this at the
top of the routine.

[ WalkSub i j k df movewith thedir old_loc;
    if (location == middlelake) "So you're God and can walk on water now?";

    ! first, check if any PushDir object is touchable

The Grammar for run/walk would look like this if you used the WalkSub:

Verb 'run' 'walk'
    *                                           -> VagueGo
    * noun=ADirection                           -> Walk
    * noun                                      -> Enter
    * 'into'/'in'/'inside'/'through' noun       -> Enter;

Well, that’s how I would do it. I’m sure there’s a way to read Go from the boat object, but I would
read it from the Room Object because that’s the way Inform is designed. I try to stick with the way
Inform is set up, avoiding those game crashing bugs.

Just my two cents :slight_smile:

  • D

Inform will put the direction object (n_obj, s_obj, or the like) in the “noun” variable.

To find the room to a particular direction, you’d do something like:


Be sure to check it against 0.

You will need to tweak that if you have places where the direction properties point to routines or strings.