Here is the story:
The Fruzzle is an animal.
The description of the Fruzzle is "An animal about the size of a big cat. It is covered in soft lavender fur. It has a long pointed muzzle. The dark band of fur across it’s eyes makes it look like it is wearing a mask. It’s long furry tail is covered in pumpkin colored splotches. "
The Fruzzle has a number called fear.
The fear of the Fruzzle is 0.
The large nut is a thing. “A heavy brown nut about the size of a couple of golf balls”
The forest is a room.
The Fruzzle is in the Forest.
Every Turn when the player is in the Forest:
say "fear is [the fear of the Fruzzle].";
Increment fear of the Fruzzle.
This story works just like you would expect it to. The fear is displayed and then incremented each turn.
Let’s build on this working example. Now we are going to add some behavior changes for the Fruzzle. We let it show it’s agitation when it’s fear is equal to three.
The forest is a room.
The Fruzzle is in the Forest.
Every Turn when the player is in the Forest:
say "fear is [the fear of the Fruzzle].";
If the fear of the Fruzzle > 3,
Say "The Fruzzle begins to sway from side to side. It makes a funny noise that sounds like a warning.";
Increment fear of the Fruzzle.
Success! This story works just like you would expect. The fear is displayed and incremented each turn. Once fear passes 3 we get the new “say”.
So now we would like to let the Fruzzle escalate it’s response as it’s fear rises even higher. So when it’s fear passes 5 it will give us a new more aggressive response.
The forest is a room.
The Fruzzle is in the Forest.
Every Turn when the player is in the Forest:
say "fear is [the fear of the Fruzzle].";
If the fear of the Fruzzle > 5,
Say "The Fruzzle has become quite agitated. It stands on it's back legs, with it's fur on end. It is now hissing and showing it's formidable fangs.";
else If the fear of the Fruzzle > 3,
Say "The Fruzzle begins to sway from side to side. It makes a funny noise that sounds like a warning.";
Increment fear of the Fruzzle.
But wait a minute, we now find that there is a translation error:
This is the report produced by Inform 7 (build 6E72) on its most recent run through:
Problem. You wrote ‘else If the fear of the Fruzzle > 3, Say “The Fruzzle begins to sway from si […] noise that sounds like a warning.”’ : but structural phrases like ‘if’, ‘repeat’, ‘while’ or ‘otherwise’ can’t be used as part of the abbreviated form of other structural phrases, so for instance ‘if in darkness, repeat with X running through rooms’ is not allowed because the ‘repeat’ is too important a phrase to be put at the end of a simple ‘if’ like this. Instead, the ‘if’ must be written out in full, so for instance ‘if in darkness begin; repeat … begin; …; end repeat; end if;’ would be fine.
See the manual: 11.8 > Otherwise
This rule tells us we have pull if out on it’s own. By the way, 11.8 makes no mention of this rule. The rule also says that repeat is too important to be put in a simple if.
Small rant follows:
In other languages, I believe the if structure allows us to write anything in a block that can go in a block.
If (condition)
“true” block
else
“false” block.
We can say things like this (I don’t know why anyone would want to)
read record
If (condition)
begin
repeat while not end of file
begin
if record-key is odd
begin
If first time
begin
open discard file
end
Write record to discard file
end
read record
end
end
else
begin
……
end
So much for the rant. To get back on track, I pulled the If out of the “Every turn” and gave it its own full block structure. Revised code now reads:
The forest is a room.
The Fruzzle is in the Forest.
Every Turn when the player is in the Forest:
say "fear is [the fear of the Fruzzle].";
Increment fear of the Fruzzle.
If the fear of the Fruzzle >5 begin;
Say "The Fruzzle has become quite agitated. It stands on it's back legs, with it's fur on end. It is now hissing and showing it's formidable fangs.";
end if,
else
Say "The Fruzzle begins to sway from side to side. It makes a funny noise that sounds like a warning."
Yup now I have a new set of translation errors:
This is the report produced by Inform 7 (build 6E72) on its most recent run through:
Problem. You wrote ‘If the fear of the Fruzzle >5 begin’ : but I can’t find a verb that I know how to deal with. This looks like an ‘if’ phrase which has slipped its moorings, so I am ignoring it. (‘If’ phrases, like all other such instructions, belong inside definitions of rules or phrases - not as sentences which have no context. Maybe a full stop was accidentally used instead of semicolon, so that you inadvertently ended the last rule early?)
See the manual: 11.6 > If
Problem. You wrote ‘Say “The Fruzzle has become quite agita […] and showing it’s formidable fangs.”’ : but I can’t find a verb here that I know how to deal with, so I am ignoring this sentence altogether.
See the manual: 2.17 > Review of Chapter 2: The Source Text
Problem. You wrote ‘end if, else Say “The Fruzzle begins to sway from si […] noise that sounds like a warning.”’ : but I can’t find a verb here that I know how to deal with, so I am ignoring this sentence altogether. (I notice there’s a comma here, which is sometimes used to abbreviate rules which would normally be written with a colon - for instance, ‘Before taking: say “You draw breath.”’ can be abbreviated to ‘Before taking, say…’ - but that’s only allowed for Before, Instead and After rules. I mention all this in case you meant this sentence as a rule in some rulebook, but used a comma where there should have been a colon ‘:’?
And what do you think the first error is ? An if can’t exist unless it is inside another structure. So you go to the page 11.6 to find out what to do. It is entirely silent on the point. In fact all of the examples are shown inside of no context.
It looks like I have two rules: one that says I have to put “if” inside of another structure; one that says not to. I am hoping there is some way to evaluate a condition which allows nesting of tests. Anybody know what it is?