How do I make 'if's inside 'if's work?

–1 vote
82 views
asked Aug 6 in Authoring by anonymous
recategorized Aug 7 by Dannii

I need help from someone who fully understands Inform 7.

My code

The manual doesn't throw specifics about this.
As you can see, I got:
if [condition] begin;
[a load of 'if' commands]
end if

Inform seems to just read the first command from the whole and ignores the rest.

Which is the problem?

2 Answers

0 votes
answered Aug 6 by bg (692 points)
edited Aug 6 by bg
 
Best answer

To answer the question in general ("How do I make ifs inside ifs work"), the if conditions need to be indented or to use "begin." To indent them, you'd do something like this:

Instead of waking your children:
    if the safety check is less than 4:
        say "You'll have time for that...";
    if the safety check is 5:
        if the consciousness of your children is 0:
            say "Snachala...";

and so on. See ยง11.7. Begin and end in the Inform manual.

As for your specific case, I haven't tested it because I'm not eager to retype the whole example.

asked Aug 6 in Authoring by Golliat
recategorized Aug 7 by Dannii
How do I make this specific code work?
0 votes
answered Aug 7 by aika (3 points)

Firstly, if you paste the code rather than screenshot it'll be a lot easier for us to help you!

Anyway my best guess is that inform is understanding "the consciousness of your children" and "consciousness of your children" as different variables. But that might not be it.

In any case, I would put a line like this right at the start of your rule to help with debugging:

say "Var 1: [the consciousness of your children] Var 2:  [consciousness of your children].";
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...