I had a similar desire in my game (an old one that I never finished). The solution involved two parts:
1) Override the core exit types and add a field to indicate the direction.
2) Override the "go" command to store the last exit the player traversed into the pov object.
With those two pieces, you can then query "game.pov.lastExit.direction" to find out what the last direction was.
Here is the code to add to your game:
<command name="go" pattern="[go]" unresolved="[UnresolvedLocation]">
if (exit.visible) {
if (exit.locked) {
msg (exit.lockmessage)
}
else if (exit.runscript) {
if (HasScript(exit, "script")) {
do (exit, "script")
}
}
else if (exit.lookonly) {
msg ("[UnresolvedLocation]")
}
else {
game.pov.parent = exit.to
game.pov.lastExit = exit
}
}
else {
msg ("[UnresolvedLocation]")
}
</command>
<type name="northdirection">
<inherit name="compassdirection" />
<alias>north</alias>
<alt type="simplestringlist">n</alt>
<direction>northdir</direction>
</type>
<type name="northwestdirection">
<inherit name="compassdirection" />
<alias>northwest</alias>
<alt type="simplestringlist">nw</alt>
<direction>northwestdir</direction>
</type>
<type name="westdirection">
<inherit name="compassdirection" />
<alias>west</alias>
<alt type="simplestringlist">w</alt>
<direction>westdir</direction>
</type>
<type name="southwestdirection">
<inherit name="compassdirection" />
<alias>southwest</alias>
<alt type="simplestringlist">sw</alt>
<direction>southwestdir</direction>
</type>
<type name="southdirection">
<inherit name="compassdirection" />
<alias>south</alias>
<alt type="simplestringlist">s</alt>
<direction>southdir</direction>
</type>
<type name="southeastdirection">
<inherit name="compassdirection" />
<alias>southeast</alias>
<alt type="simplestringlist">se</alt>
<direction>southeastdir</direction>
</type>
<type name="eastdirection">
<inherit name="compassdirection" />
<alias>east</alias>
<alt type="simplestringlist">e</alt>
<direction>eastdir</direction>
</type>
<type name="northeastdirection">
<inherit name="compassdirection" />
<alias>northeast</alias>
<alt type="simplestringlist">ne</alt>
<direction>northeastdir</direction>
</type>
<type name="updirection">
<inherit name="updowndirection" />
<alias>up</alias>
<alt type="simplestringlist">u</alt>
<direction>updir</direction>
</type>
<type name="downdirection">
<inherit name="updowndirection" />
<alias>down</alias>
<alt type="simplestringlist">d</alt>
<direction>downdir</direction>
</type>
<type name="indirection">
<inherit name="inoutdirection" />
<alias>in</alias>
<alt type="simplestringlist"></alt>
<direction>indir</direction>
</type>
<type name="outdirection">
<inherit name="inoutdirection" />
<alias>out</alias>
<alt type="simplestringlist">o</alt>
<direction>outdir</direction>
</type>
The direction fields have names like "northdir", "southdir", etc. I decided to go that route rather than using (say) the "alias" field, as those other fields were user-facing and would be changed if the game were ever translated to a non-English language.
Let me know if you need anything clarified. I believe if you just drop that in your game somewhere (e.g. before the closing </aslx> element), then it should just work.
As always, be sure to backup your game before doing any major mods like this...