if statements

When writing if statements, is there a difference between:

After [some condition]:
       If the [sub-condition is true]:
           do this;
       Else if [some other sub-condition is true]:
            do this;

and

After [some condition]:
       If the [sub-condition is true]:
           do this;
       If [some other sub-condition is true]:
            do this instead;

and

After [some condition]:
       If the [sub-condition is true]:
           do this;
       Otherwise if [some other sub-condition is true]:
            do this;

Basically, I’m just curious if there’s a difference between using “else if”, “otherwise if”, or using “if… instead”. I just learned that there is a subtle difference between “There is a box in the room. The box is a container.” and “A container called a box is in the room.” So I’m wondering if some subtle difference also exists for the if statements.

“else” and “otherwise” are exactly the same.

Your first and second examples will have different results if both sub conditions are true.

So then what purpose does “instead” serve?

“Instead” does a few things:

It immediately stops the current rule.

It stops the rulebook.

It may stop the action. It’s been a while since I’ve checked the details, but I think that “instead” in a before rule will stop the action from continuing on to the carry out and reporting phases. I’m not sure what will happen if “instead” is used in an after rule.

Cool, thanks. :slight_smile:

Notably, the relevant difference between your first and second examples is the “else if”, not the “instead”.

Okay, so in that case, what exactly is the difference between:

After [some condition]: If the [sub-condition is true]: do this; Else if [some other sub-condition is true]: do this;

and

After [some condition]:
       If the [sub-condition is true]:
           do this;
       Else if [some other sub-condition is true]:
            do this instead;

?

In the first bit of code, when you hit the second subcondition the action is considered to have “succeeded.” In the second bit of code, when you hit the second subcondition the action is considered to have “ended without result.” You can see this by testing this code:

[code]Lab is a room.

The player carries a rock.

After jumping:
if the player carries the rock:
say “Rock jump 1.”;
otherwise if the player does not carry the rock:
say “Rock jump 2.” instead.

Test me with “actions/drop rock/jump”.
[/code]

with and without the final “instead.”

OTOH, whether an action succeeds or ends without result doesn’t usually make a difference unless you’ve got something else that particularly relies on it.

(Note that “After” rules have default outcome success, which means that they stop the action unless there’s an explicit “continue the action.” In a “Before” or “Check” rule the “instead” would be the difference between the action stopping and continuing.)

Ok, so I’ve tried looking at different conditions of your example (using a “before” rule, a “check” rule, a “carry out” rule, and a “after” rule, and all of them with or without the “instead”). I see what’s happening, but I’m not sure I fully understand what’s happening.

So adding the “instead” with a “before” or “check rule” (before the action occurs) will keep the parser from continuing/carrying out the action, stopping the process right then and there if that particular subcondition is true (in this case, not carrying the rock, so the player-character does not “jump on the spot”). The same appears to be true for an “After” rule, but it’s practically irrelevant at that point since the printed results that the player sees are basically identical anyway.

The “carry out” rule seems to be a little different. Regardless of whether the “instead” is there or not, the action will succeed.

Yes?

You can think of the “instead” phrase as your easy way to cancel an action at any time before the “carry out” phase begins. When the carry out phase begins, the idea is every possible check rule has run and passed and the action is definitely going to happen.

Check entering the canoe: if the player does not carry an oar: say "You'd rather not be up this creek without a paddle." INSTEAD; [rule fails, action stops] if the player does not wear a life jacket: say "The rapids are pretty rough, you need to be wearing a floatation device." INSTEAD; [rule fails action stops] if a hole is part of the canoe: say "Hey, this canoe is leaky! You're glad you noticed this! You'll need to notify the camp counselor."; INSTEAD [...] if Bob has not learned to swim: say "Bob is not skilled up enough to be your canoe race partner." INSTEAD;

Now, in the carry out phase, the action has passed every safety check and is going to happen and here’s where all the world manipulation takes place “carrying out” the action.

[code]Carry out entering the canoe:
Try bob entering the canoe;
now racephase is 1;
now bob wears a random off-stage life jacket;
now bob carries a random off-stage oar;
now the canoe is in At the Starting Line.

Report entering the canoe:
say “You and Bob settle into the boat and paddle toward the starting line, ready to win the canoe race!”[/code]

After rules run before report rules and interrupt them so you can trigger new actions and give the player an alternate “report”…

After entering the canoe when bob has not eaten breakfast: say "'I am starving, I hope I have enough energy to win the race!' Bob complains. You quickly divert the canoe to the paddle-through window of the camp cafeteria to order Bob a breakfast sandwich."; now the canoe is in Waiting To Order.

If Bob has eaten breakfast, this After rule should not fire and you’ll get the standard report rule.

(You’d use a decide rule for this bit of weirdness:)

To decide if Bob has eaten breakfast: If Breakfast with Bob has happened: [Breakfast with Bob being a scene] decide yes; decide no.