Inform7: Shipboard directions: How to understand s as starboard and not as south?


I’m writing a piece of IF (in Inform7) that takes place on a ship. So, of course, I want to use shipboard directions, and I don’t really need any other directions.

Just to remind ourselves, shipboard directions are fore, aft, starboard, and port. :slight_smile:

For the convenience of the player, I want to use the respective abbreviations f, a, s, and p.

In particular, I want to write

Understand “s” as starboard.

Of course, my abbreviation s for starboard collides with the predefined abbreviation s for south from the standard rules:

Understand “s” as south.

I found the following two implementations of shipboard directions.

First, the extension Shipboard Directions by Mikael Segercrantz ( ).
This extension uses the abbreviation sb for starboard, so there’s no collision with the abbreviation s for south.
That is certainly a viable option, but as I said above, I don’t want to do this.

Second, example #42 from “Writing with Inform”.
This example uses the abbreviation s for starboard and thus has a collision with the abbreviation s for south.
To get around this problem, the extension uses the following phrase.

Does the player mean going a nautical direction when the location is nautical: it is very likely.

Without this phrase, the response to the player’s input s is:

Which do you mean, the south or the starboard?

Since I have only nautical locations and no non-nautical locations, I can remove the when-condition from the above phrase and simplify it to

Does the player mean going a nautical direction: it is very likely.

With this, I get rid of Inform’s response-question

Which do you mean, the south or the starboard?

However, I wonder if there is another way of undoing the definition

Understand “s” as south.

from the standard rules (other than altering the standard rules file, of course).

More generally, if there is a definition

Understand “x” as y.

that may come from my own code, or from an extension, or from the standard rules,
is there an easy way to make Inform completely forget that definition at some point in the game?

Thanks for your help.


What course has your ship ? starboard can became synonymous with south :wink:

Best regards from Italy,
dott. Piergiorgio.

I’ve seen several threads say that you can copy a section of the Standard Rules into your game and modify it: for instance Is there any way to override the direction commands?

If you don’t ever need the usual directions that seems to be the way to go… If you want to switch back and forth I gather it’s more complicated.

1 Like

Counterfeit Monkey switches to nautical directions at one point. You can see how the author defines it in the source code:

The relevant section in the CM source linked above:

There’s a couple of different issues here. For most commands, the underlying “Understand” involves understanding a verb as an action, as in

Understand "sing" as singing.

In a case like this, you can eliminate all the existing grammar for the word “sing” by saying

Understand the command "sing" as something new.

That eliminates all the Understand lines for the verb “sing.”

Or you can eliminate all the existing grammar for an action by saying

Understand nothing as singing.

That eliminates all existing grammar lines that get redirected to singing (but if there’s another grammar line for a verb like “sing,” it’ll stay in.)

This is discussed in §17.3 of Writing with Inform.

HOWEVER this doesn’t apply to the case of directions, because directions are objects rather than actions. So the relevant lines in the Standard Rules like

Understand "s" as south.

can’t be overridden in the way I’ve just described–they only work for verbs and actions. There’s no general way to override this kind of line (partly because I think the abbreviations for directions are the only understand-as-a-noun lines built into the Standard Rules). If you want to override that you have to replace the relevant section of the Standard Rules, in the way JoshGrams described.

The “Understand the command… as something new” lines work at compile time, they can’t be triggered in the course of play. So if you want an Understand line to be overridden some of the time, you have to make it an “Understand… when” as in the excerpts from Counterfeit Monkey that folks linked. That can work for nouns or verbs:

Understand "sing" as singing when the location is the Auditorium.
Understand "p" as port when the location is nautical.

(You’d want to be a little careful about this as it applies to command, as in most cases it’s not great design to have the parser fail to understand a verb in one setting and understand it in another setting–if the player tries a verb and is told “That’s not a verb I recognise” then they will be likely to not try it again in the setting that it works. It can be best to have it understood everywhere with a failure message if you use it in the wrong place. Though there can be reasons not to do it that way.)

1 Like

I should have mentioned it’s a spaceship. So your - otherwise very creative - solution doesn’t apply here. :slightly_smiling_face:

You could just use room names and not cardinal directions.

at this point, also the majority of the standard directions don’t apply, 8 of them being based on planetary magnetic field :smiley:

OTOH, if all your work is aboard the starship, without landing(s), you can simply replace the “magnetic compass” directions with the Naval ones.

Best regards from Italy,
dott. Piergiorgio.