Inform 7 Home Page / Documentation

§18.6. Activity variables

Just as actions can have variables, which are created when the action starts and disappear when it finishes, so activities can also have variables. They are visible to the rules for that activity, and nowhere else. (If the activity should happen a second time within its first run, that second occurrence gets its own copy of the variable, leaving the original untouched.)

Typically it will be useful to set a variable to some default value at the "before" stage, calculate some interesting value for it in the "for" stage, and make use of the outcome during the "after" stage. For instance:

Analysing something is an activity. The analysing activity has a text called first impression. Instead of examining something (called the sample), carry out the analysing activity with the sample.

Before analysing: now the first impression is "unremarkable".

Rule for analysing someone: now the first impression is "living tissue".

After analysing something (called the sample):
    say "Your professional opinion of [the sample] is that it is
        [first impression]."

arrow-up.png Start of Chapter 18: Activities
arrow-left.png Back to §18.5. New activities
arrow-right.png Onward to §18.7. Beginning and ending activities manually