Variables

Ok. Not sure why I am having such an issue with this. I just want some sort of variable that I can turn on and off to track story progress.

I keep trying to use “let” and “now” but I keep getting translation errors.

So I might say something like:

now StoryPointO1 is 1;

And it says “I am reading the sentence ‘now StoryPointO1 is 0’ as saying that a thing called ‘now StoryPointO1’ is a value, but this makes no sense to me - it would be like saying ‘the chair is 10’.”

I do something like:

let StoryPointO1 be 1;

And that seems to work, but if I try to put it into a “say” to see if it worked. Like:

say "Story Point O1 is [StoryPoint01]";

And it says "I was expecting that ‘StoryPointO1’ would be something to ‘say’, but it didn’t look like any form of ‘say’ that I know. So I tried to read ‘StoryPointO1’ as a value of some kind (because it’s legal to say values), but couldn’t make sense of it that way either. "

So what am I doing wrong?

Did you place that instruction inside a rule? Control statements can’t live outside a rule, because then, Inform won’t know when they apply.

It looks like in one place you have “StoryPointO1” with a capital O and in another you have “StoryPoint01” with the number zero.

Anyway, “let StoryPointO1 be 1” will create StoryPointO1 as a temporary variable that lasts only for the length of the rule or phrase that it’s defined in. If you want a global variable, you have to define it first and then set it:

StoryPointO1 is a number that varies. [or I think "number variable" also works] Carry out jumping [or whatever rule]: now StoryPointO1 is 1.

Another way to do this is just to set the initial value of the variable:

StoryPointO1 is 0.

and Inform will figure out that it’s a number variable.

…by the way, if you just want to turn it on and off, you don’t have to use a number, you can use a truth state variable that gets set to true or false, and you can give it multi-word names that are easier to remember.

[code]Jumped in the ballroom is a truth state that varies. [will get set to false by default]

After jumping in the ballroom when jumped in the ballroom is false:
say “You have jumped in the ballroom! This will have profound effects of some sort.”;
now jumped in the ballroom is true.[/code]