inform7

Inform 7 error using If player consents


I'm trying to write a piece of interactive fiction using inform 7, I want to put a choice in there for the player and I want a simple yes or no I used the following code:

if the player consents say "You get a better view of the stranger."

Otherwise:
say "You can't make out what's happening clearly, however, you notice the stranger walking out of the pub" 

I then get this useless error message:

You wrote 'if the player consents say "You get a better view of the stranger."' : but I can't find a verb that I know how to deal with. This looks like an 'if' phrase which has slipped its moorings, so I am ignoring it. ('If' phrases, like all other such instructions, belong inside definitions of rules or phrases - not as sentences which have no context. Maybe a full stop or a skipped line was accidentally used instead of semicolon, so that you inadvertently ended the last rule early?)

Any help would be greatly appreciated.


Solution

  • The punctuation is off. Phrases should end with a semicolon, and if phrases should use either begin..end blocks, or the "colon-and-indentation" style. So either:

    if the player consents begin;
    say "You get a better view of the stranger.";
    otherwise;
    say "You can't make out what's happening clearly, however, you notice the stranger walking out of the pub";
    end if;
    

    or

        if the player consents:
            say "You get a better view of the stranger.";
        otherwise:
            say "You can't make out what's happening clearly, however, you notice the stranger walking out of the pub";
    

    Note the colons and semicolons and tabs in the second example.

    Also, as the error message says, you need to specify when that question should be asked. If phrases must be inside rules or phrases. For example, if the question should be asked as a result of an action:

    After examining the stranger for the first time:
        say "Move closer?";
        if the player consents begin;
        say "You get a better view of the stranger.";
        otherwise;
        say "You can't make out what's happening clearly, however, you notice the stranger walking out of the pub";
        end if;