Indentation issues with if, otherwise

Here’s a simple chunk of Inform 7 that’s supposed to ask the player for a password when they open the laptop; however, as much as I’ve tried to ensure proper indentation, I still get the error that includes “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 ‘if the player’s command matches “secret”’, in case that helps.

After opening laptop:
    say "You must login first!";
    now the command prompt is "Password: ".

After reading a command when the command prompt is "Password: ":
    if the player’s command matches "secret":
        say "Welcome!";
    otherwise:
        say "Wrong!";
        now the command prompt is ">";
        reject the player's command.

For context, I’m using borogove.app, and while I’ve encountered this error before, I’ve been able to remedy it (although I don’t have access to the code I’ve fixed in the past, at the moment, and I don’t have a local copy of Inform 7 running on this laptop either).

I’ve searched through similar articles and can’t seem to find what I’m after, although it’s not impossible I’ve overlooked something. Any pointers on what could be off?

Cheers!

Your code as written compiles (with appropriate tabs used) as is in ni; I suspect the difficulty is in Borogove’s text editor’s handling of the tabs or something like that.

I hope this answer doesn’t color too far outside the lines of your question, but I found getting tabs to work to be too much trouble in general and gave up.

After reading a command when the command prompt is "Password: ":
  if "[the player's command]" exactly matches the text "secret" begin;
    say "Welcome!";
  else;
    say "Wrong!";
    now the command prompt is ">";
    reject the player's command;
  end if.

I’m stuck with them for tables and the case-statement-like form of If, of course.

(And I’m pretty sure if the player’s command matches "secret": won’t work 'cause snippets have to be matched against topics not texts. But as I did above, you can convert the snippet to text and compare that to text. But it becomes “exactly matches” instead of “matches” for text comparison, because.)

1 Like

I’m pretty sure it would work, because "double-quoted strings" in the source are compiled as text or topics as required by context.

1 Like