Inform 7: A problem with 'otherwise'--can anyone help?

I’m trying to create a section where the player needs to ride on amusement part ride with another person in the car in order to receive something from a locked glass case after the ride. Here’s the code I’m using, with game info redacted and (tab) representing a single tab of space:

Instead of entering the small car:
(tab) if the glass case is open, say “TEXT NO NEED TO RIDE AGAIN.”
(tab) otherwise if Alice is visible:
(tab) (tab) say “TEXT RIDE WITH ALICE.”;
(tab) (tab) now the glass case is open.
(tab) otherwise:
(tab) (tab) say “TEXT RIDE ALONE.”

Inform has a problem with the second ‘otherwise’, but I can’t find anything wrong with it. The error message I get is the following:

“You wrote ‘otherwise’ : but the punctuation here ‘:’ makes me think this should be a definition of a phrase and it doesn’t begin as it should, with either ‘To’ (e.g. ‘To flood the riverplain:’), ‘Definition:’, a name for a rule (e.g. ‘This is the devilishly cunning rule:’), ‘At’ plus a time (e.g. ‘At 11:12 PM:’ or ‘At the time when the clock chimes’) or the name of a rulebook, possibly followed by some description of the action or value to apply to (e.g. ‘Instead of taking something:’ or ‘Every turn:’).”

This isn’t too useful. I’m sure I’m probably just missing something obvious, but I can’t see it. Can anyone help?

You need semicolons at the end of the second and fourth lines–since they end with periods Inform thinks that “otherwise:” is starting a new code block.

The error message is confusing, but it’s happening because Inform is processing it like this:

Instead of entering the small car:
(tab) if the glass case is open, say “TEXT NO NEED TO RIDE AGAIN.”

(tab) otherwise if Alice is visible:
(tab) (tab) say “TEXT RIDE WITH ALICE.”;
(tab) (tab) now the glass case is open.

(tab) otherwise:
(tab) (tab) say “TEXT RIDE ALONE.”

So it’s trying to interpret “otherwise:” as the heading of a rule, phrase, or definition, and that’s not working.

(I wonder if it might be good for the compiler to issue a special message for standalone “otherwise:” and “If blahblahblah:” headers which are often going to be punctuation problems, or maybe programmers who don’t know those need to be wrapped in rules.)

That gets me this result:

Problem. You wrote ‘otherwise if Alice is visible’ : but this doesn’t match a corresponding ‘if’, as it must. An ‘otherwise’ must be vertically underneath the ‘if’ to which it corresponds, at the same indentation, and if the ‘otherwise’ uses a colon to begin a block then the ‘if’ must do the same.


Problem. The phrase or rule definition ‘Instead of entering the small car’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure. The first phrase going awry in the definition seems to be ‘say “TXT RIDE WITH ALICE.”’ , in case that helps.

This sometimes happens even when the code looks about right, to the eye, if rows of spaces have been used to indent phrases instead of tabs.

(I did use tabs, so I don’t think that’s it)
What I’m trying to do it create the following results if the player enters the car:
If the player has already gotten the case open, you get a message saying you don’t need to ride again.
If that’s not true, but Alice is there, you go on the ride and the door to the case opens.
If neither is true, then you get the ‘standard’ text for going on the ride.

Wup, nevermind, I got it to compile. The trick turned out to be putting the other two options under ‘otherwise if the glass case is closed’ rather than having them all in a row. I still don’t get what the difference is, but if it works, it works. Thanks for your help!

When you write a rule with colon-tab syntax, you have to use colon-tab syntax all the way through. You can’t have one line of “if foo, bar”.