First time authoring, quite the slew o' questions.

So, I just started working with Inform 7. I’ve been learning by using a combination of the brasslantern.org guide, the Inform 7 manual, and good ol’ trial-and-error. I am pretty comfortable with the straightforward activites, but am having trouble with any puzzles involving multiple conditions. For instance, at the end of my test story, I have a portal which the player must use to finish the story. The portal is activated by pulling a lever which activates the engine that powers the portal; however, before the engine can be activated, the player must find a missing gear and replace it in the engine.
At least… that’s the idea.
I have seen similar logic in other IF (Curses comes to mind, where the flashlight cannot be switched on unless you put in a fresh battery), so I assume the verbage exists in Inform; however, everything I have tried results in either an error or is simply non-functional. I have tried using an instead of statement with multiple possible outcomes; however I cannot get Inform to read the second outcome. The specific requirements I am going for are a) the rust-covered gear must be in the panel before the switch can be activated, b) if the switch is activated before the gear is in the panel, a failure message will be printed. The source text in question is currently written:

This plays out with the switch being properly functional if the gear is in the panel; however if the gear is not in the panel, no text is printed and the switch is toggled anyway.
In summation… I guess I am trying to ask if there is a better way to build a conditional switch. Inform doesn’t seem to like my cobbled-together abomination of verbage, even though it slips past the Problem catcher.
Anyway, thanks for bearing with me and being patient with a newbie IF author, and thanks for any input you can provide.

I’m not entirely certain, but it seems to me the problem is in the syntax.

Try something like this:


Instead of switching on the motor:
    if rust-covered gear is in panel:
        say "[if motor is switched off]The engine roars to life.[otherwise]The engine grinds to a halt.[endif]";
        continue the action;
    otherwise:
        say "There is a pitiful whine, but nothing happens.";
        stop the action.

From what I could tell, your example checked if the gear were in the panel, printed the text if it were, and continued the action, so it never got to checking if the gear weren’t in the panel.

I don’t really use the “if … , do something.” syntax, because I’m never sure where to indent. The above feels clearer to me.

Hey there!

This seems to me like an issue with the colon-and-indentation syntax. As it is now, your code basically checks whether the gear is in panel. Then, after the check is complete, it executes “continue the action”, meaning instructions beyond that point cannot be reached.

This will technically work.

Instead of switching on the motor:
	If rust-covered gear is in panel:
		say "The engine roars to life.";
		continue the action;
	If rust-covered gear is not in panel:
		say "There is a pitiful whine, but nothing happens.".

(Using the code tag on the forum instead of the quote tag allows you to preserve tab spaces.)

I already removed one part that will never be reached (you will never switch off a machine through the switching on action after all, and ‘stop the action’ is implicit in Instead rules). However, ‘continue the action’ is not needed. I get the sense you use it to mean ‘continue this instruction set’, but what it really does is continue the switching on action; in other words, it will print out “You switch on the engine.” after printing “The engine roars to life.”

I’d do this by changing the report rules rather than using one single instead rule.

Instead of switching on the motor when the rust-covered gear is not in panel, say "There is a pitiful whine, but nothing happens.".

Report switching on the motor: say "The engine roars to life." instead.
Report switching off the motor: say "The engine grinds to a halt." instead.

That’s good, because using that syntax precludes indenting. :stuck_out_tongue:

In short, “if X is true, say Y;” is a complete logical statement. After the semicolon, the condition ends. You use colon and indentation to create a multi-row condition:

If x is true: say "Permit me to introduce myself,"; say "I am a man of wealth and taste.".

Thanks for all the responses! I used Eleas’ suggestion and it seems to be doing what I wanted.