What have I done wrong with my "otherwise if" statement?

Here’s what I have written down:

After shooting:
If shooting Jane:
say “Good. She was a murderer!”
Otherwise if shooting Joe:
Say “Joe was innocent!”

And here is the message I get when trying to test play

Problem. You wrote ‘Otherwise if shooting Joe’ 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:’).

1 Like

You should end lines within the rule blocks with a semicolon, and the last line with a period.

I believe this should work:

After shooting:
If shooting Jane:
say “Good. She was a murderer!”;
Otherwise if shooting Joe:
say “Joe was innocent!”.

2 Likes

Excellent! this has worked. Thank you! ^-^

Actually it’s legal to end the last line with either a period or a semicolon. I prefer the latter, since if I later need to add clauses for some reason, I don’t need to remember to change the period should that line end up no longer being the last one.

e.g.

[illegal code, won't run] 

After shooting:
    if shooting jane:
        say "Good. She was a murderer!";
        end the story saying "Hurrah! Justice has been served.";
    otherwise if shooting joe:
        say "Joe was innocent!".                       [you'll get complaints about the period, here.]
        end the story saying "Alas, a bloody tragedy.";

[legal]

After shooting:
    if shooting jane:
        say "Good. She was a murderer!";
        end the story saying "Hurrah! Justice has been served.";
    otherwise if shooting joe:
        say "Joe was innocent!";
        end the story saying "Alas, a bloody tragedy.";

5 Likes

I generally use the period to end a rule block and use semicolon for lines inside a rule block. It just seems logical to me. @Dizzydonut Are there any places in your code that you do use the period or do you only use semicolons throughout all of your code involving rule blocks?

I do agree, this is a pretty good reason to not use the period in a rule block!

1 Like

I always use semicolons, never periods. It just seemed to me to be one less mistake to make – and I make plenty!

1 Like

That’s a good plan as long as you’re in the habit of putting blank lines between your rules and other top-level declarations. (Which I am.) If you don’t use blank lines or periods, Inform can get confused about where a rule ends.

3 Likes