Instead...instead

How do I predict when to put multiple instances of “instead” in a conditional? I see no rhyme or reason to it. Thank you.

Do you have any examples of what you have in mind? (I don’t really think of instead having much to do with conditionals – they’re attached to particular instructions, which may or may not be in a conditional – but perhaps I misunderstand what you’re after.)

I’m not sure I understand what you want to do either. Can’t you just start with “instead of (some action):” and then your conditionals?

Add me to the list of fairly confused folks too, but I think you might mean a rule like this:

Checking taking an egg:
    If the noun is speckled, say “that’s not the one you want.” instead;
    If the noun is jumbo and the hen is in the coop, try talking to the hen instead;

If that’s the case there’s not much rhyme or reason - the number of insteads just depends on the number of cases you want to handle that way.

What I want is to understand why “instead” is repeated apparently redundantly in examples like the following. There are many other such examples in the Inform7 documentation, in the recipe book, and in tutorials on YouTube. Thank you.

From page 338 of I7Handbook6x9:

Instead of examining something when the player is not wearing the glasses:
try looking instead.

[By the way, conceptually that’s a form of conditional; “when the player is not wearing glasses” is a restricting/sufficient condition; in a manner of speaking so is “instead of examining”.]

[edit: removed the if-else + instead example; it wasn’t actually redundant]

This is from Section 18.5 of the Inform7 documentation:

Instead of listening in the presence of the switched on radio:
carry out the showing action activity with the radio instead.

Section 8.4:

Instead of opening a chest when something is on a lid (called the item) which is part of the noun:
say “You’d have to remove [the list of things on the item] from the lid first.” instead.

Section 9.4

Instead of taking a cork when the noun is in a bottle (called the item):
move the noun to the player;
say “You pull [the noun] from [the item].” instead.

Ah, I see - so some of those are what I was talking about, where different “insteads” are basically just different off-ramps from the rule, since “instead” within the text of a rule tells Inform “stop running this rule and go do this other thing.” That can be helpful if, for example, there are two conditions that might be satisfied but you only want one set of logic to fire (like say if a door is both locked and closed, you would want just the “this is locked” response if the player tried to go through it - dumb example since the basic rules take care of stuff like that but the principle is the same).

The other thing you’re asking about seems like it’s why “instead” is showing up in the rule preamble (like, “instead of examining”) as well as in the text of the rule? There, the “instead” is telling Inform when it should consult this rule and how that interacts with the regular order in which it processes rules (this bit of the docs spells out the details, including a handy flow chart).

Basically they’re separate questions - when you write a rule, first you want to ask yourself “when should this rule fire” - and the answer to that might push you to an instead rule - and then “what should happen once the rule is running” - which in turn might mean you want to write some instead statements terminating them when certain conditions are met.

(NB as to the first point, usually you don’t want to use an instead rule rather than a carry out rule or something like that! See this thread).

1 Like

Actually, I don’t find that case odd. The first occurrence of “instead” looks clunky because of the preceding period, but as we know, that period belongs to the user-end display text and not to the syntax of the instructions. When the code runs, if the first condition fails (that is, if the noun is not speckled), then the consequent of that line is skipped (and so the “instead” in that line is skipped); likewise for the second line. But I do appreciate the solidarity with my question.

1 Like

Our last messages crossed, but I’ll have to look at your response in the morning. It’s late. Thanks!

1 Like

The instead phrase modifier means “stop the current action and do this other thing instead”. It’s most often seen in Before and Check rules. It’s usually not especially useful in Instead and After rules, because Instead and After rules already, by default, stop the action.

But it’s imaginable you could have an Instead or After rule that ends with continue the action and it could be useful to have an instead inside a conditional within that rule.

1 Like

There are some nuances here that have to do with the way that rulebooks function on a deeper level.

The keyword instead at the end of a statement means that the routine implementing the rule should be immediately exited, which may cause a rulebook result that is different from the default for that rulebook. For example:

Instead of jumping:
    say "Not today."

Instead of waving hands:
    say "Meh." instead.

The Instead rulebook has a default outcome of failure (as can be seen in the Index). Note the slight difference under the hood, though:

>ACTIONS
Actions listing on.

>JUMP
[jumping]
Not today.
[jumping - failed]

>WAVE
[waving hands]
Meh.
[waving hands - ended without result]

Similarly for a given action’s Check rulebook, which has a default outcome of no result (if I’m not mistken):

Check jumping:
    say "Not today."

Check waving hands:
    say "Meh." instead.

yields

>JUMP
[jumping]
Not today.

You jump on the spot.
[jumping - succeeded]

>WAVE
[waving hands]
Meh.
[waving hands - failed the Check waving hands]

There is more detail here, but it’s probably not of much interest unless you’re trying to influence the results coming out of the rulebooks in question.

1 Like
Instead of jumping:
    say "Not today."

Instead of waving hands:
    say "Meh." instead.

The Instead rulebook has a default outcome of failure (as can be seen in the Index). Note the slight difference under the hood, though:

>ACTIONS
Actions listing on.

>JUMP
[jumping]
Not today.
[jumping - failed]

>WAVE
[waving hands]
Meh.
[waving hands - ended without result]

That’s certainly an oddity. You’ve answered my question. Thank you.

Thanks. The flow chart answered another question I had (Q: why bother with “stop the action” after replacing the action with another using instead? A: to stop the report).