Inform 7 Home Page / Documentation


§18.7. Beginning and ending activities manually

If we have declared a new activity, like "analysing", the normal way to make it happen would be to write

carry out the analysing activity with the pitchblende;

which goes through the whole machinery of rules - before, for, after - and then resumes, the activity having started, taken place and come to an end.

But there are times when it is not convenient to write a suitable "for ..." rule, or where we need more control, and do not wish to hand the whole business over to a single phrase. For such times we are allowed to write:

begin the (activity) activity

This phrase causes the named activity to become active, and runs its "before" rulebook. The activity must be one which applies to nothing. Example:

begin the assaying activity;

In all cases a matching "end the ... activity" or else "abandon the ... activity" phrase must be reached.

begin the (activity on values) activity with (value)

This phrase causes the named activity to become active, and runs its "before" rulebook. The activity must be one which applies to a value of a matching kind. Example:

begin the analysing activity with the pitchblende;

In all cases a matching "end the ... activity with ..." or else "abandon the ... activity with..." phrase must be reached.

And when we are done:

end the (activity) activity

This phrase runs the "after" rulebook of the activity and then causes it to become inactive. The activity must be one which applies to nothing. Example:

end the assaying activity;

This must only happen to match an earlier "begin the ... activity" phrase.

end the (activity on values) activity with (value)

This phrase runs the "after" rulebook of the activity and then causes it to become inactive. The activity must be one which applies to a value of a matching kind. Example:

end the analysing activity with the pitchblende;

This must only happen to match an earlier "begin the ... activity with..." phrase.

So the usual structure is like so:

begin the analysing activity with the pitchblende;
...
end the analysing activity with the pitchblende;

This time the activity is ongoing throughout as many phrases as we care to write between the "begin" and "end". The before rules are considered at the time of the "begin ..." phrase; the after rules at the "end ...".

What, then, of the "for" rules? In the above setup, they would simply be ignored. But we can make them effectual thus

begin the analysing activity with the pitchblende;
...
if handling the analysing activity with the pitchblende:
    ...
...
end the analysing activity with the pitchblende;

We place the activity's normal behaviour inside the "if"; the condition, "if handling...", is true only if no rule has intervened. This means that we (or other authors using our activity) can create their own for rules to substitute here. If we elsewhere write

Rule for handling the analysing activity with the pitchblende when the player is not sober:
    say "You can't seem to focus."

that rule will intervene and take the place of whatever we have placed inside the condition.

if handling (activity) activity:

This should be used only where the given activity has been started with "begin ..." and will be finished with "end ...". It runs the "for" rules for the activity, and then comes out true if none of those for rules intervened in the handling of that activity. (The activity must be one which doesn't apply to any value.)

if handling (activity on values) activity with (value):

This should be used only where the given activity has been started with "begin ..." and will be finished with "end ...". It runs the "for" rules for the activity, and then comes out true if none of those for rules intervened in the handling of that activity. (The given value m st be the one it is being applied to.)

It is also legal to force an early end to an activity with:

abandon the (activity) activity

This phrase ends an activity at once (without consulting any further rulebooks, including its "after" rulebook). It can only be used with an activity which has had its "begin" but not yet its "end" phrase; it is a drastic remedy best taken o ly if it is clear that circumstances have changed so that the activity now seems inappropriate. It must not be used during one of the rules for the activity: it can only be used between the begin and for stages, or between the for and end stages.

abandon the assaying activity;

abandon the (activity on values) activity with (value)

This phrase ends an activity at once (without consulting any further rulebooks, including its "after" rulebook). It can only be used with an activity which has had its "begin" but not yet its "end" phrase; it is a drastic remedy best taken only if it is clear that circumstan es have changed so that the activity now seems inappropriate. It must not be used during one of the rules for the activity: it can only be used between the begin and for stages, or between the for and end stages.

abandon the analysing activity with the pitchblende;

We need to follow three golden rules: all activities must end, they must never last longer than a turn, and if activity B starts during activity A then it must also finish during activity A. We must also be careful to make sure that if an activity applies to something, then it begins and ends with the same something (the pitchblende, in the above example).


arrow-up.png Start of Chapter 18: Activities
arrow-left.png Back to §18.6. Activity variables
arrow-right.png Onward to §18.8. Introduction to the list of built-in activities