if-statementinform7

Inform7 Ignoring Simple If-statements


I've decided to try my hand at Inform7 and I'm having a lot of fun playing around and seeing what is possible with it. For the moment, and using the tutorials available to me online, I'm trying to incorporate a day/night cycle and sleeping which will become available to the player only during one of the night cycles. I've run into some trouble in the way that Inform7 is ignoring my if statements and the player is able to sleep during any time of the day, which isn't what I want. I'm sure I've overlooked something silly as I've just started out, but maybe someone would be kind enough to let me in on what I could do to fix this? Thanks so much.

I apologize for any errors in my code, please keep in mind that I am new and wanting to learn.

Here is my code. . .

The sun is a backdrop. It is everywhere. The description is "Currently out of sight."

Night is a recurring scene. Night begins when play begins. Night begins when the time of day is 10:00 PM. Night begins when Dusk ends. Night ends when the time of day is 1:30 AM.

When Night begins:
    say "The moon is up and the temperature drops abruptly to well below zero.";
    now the description of the sun is "Currently out of sight."

The witching hour is a recurring scene. The witching hour begins when Night ends. The witching hour ends when the time of day is 5:00 AM.

When The witching hour begins:
    say "You feel sleep calling you.";
    now the description of the sun is "Currently out of sight.".

Day is a recurring scene. Day begins when The witching hour ends. Day ends when the time of day is 6:00 PM.

When Day begins:
    say "The sun is now properly up.";

Dusk is a recurring scene. Dusk begins when Day ends. Dusk ends when the time of day is 10:00 PM.

When Dusk begins:
    say "The sun is setting.";
    
A person is either awake or asleep. A person is usually awake.

Every turn: 
    if The witching hour is not happening:
instead of sleeping when the player is awake:
    now the player is awake; 
    say "You can't sleep now. . .";

Every turn:
    if The witching hour is happening:
instead of sleeping:
    now the player is asleep;
    say "You fall asleep. . ."; 
    
Every turn:
    if The witching hour is happening:
instead of doing something other than waking up, waiting or sleeping when the player is asleep:
    say ". . . You're sleeping.";

Every turn:
    if The witching hour is happening:
instead of sleeping when the player is asleep: 
    say "Zzzz.";

Every turn:
    if The witching hour is happening:
instead of waking up when the player is asleep: 
    now the player is awake; 
    say "You wake suddenly.";
    
Every turn:
    if The witching hour is happening:
instead of doing something other than looking or sleeping when the player is awake: 
    say "You'd really rather just sleep. . .";

Solution

  • You can't put instead rules (or any other types of rules) inside other rules. The compiler should really throw an error there but unfortunately it doesn't. What you need to do is remove all Every turn: lines and combine all if conditions with the instead rule conditions. For example:

    Instead of sleeping when the player is awake and the witching hour is not happening:
        say "You can't sleep now. . .";
    
    Instead of sleeping when the witching hour is happening:
        now the player is asleep;
        say "You fall asleep. . ."; 
    

    and so on for the rest of the rules.