![]() | Chapter 17: Activities | ![]() ![]() |
17.5. New activities |
Activities are all about influencing the standard mechanisms which Inform uses, so it might at first seem that there is no need to create new activities: but on further reflection, quite a lot of the writing of interactive fiction involves creating new and systematic ways to do things, and as soon as we have a general rule, we will want to have exceptions. Inform therefore allows us to create our own activities, giving us ways to influence the operation of our own mechanisms.
There are two kinds of activity: those which relate to a specific thing or room, and those which do not. The following creates one of each kind:
Analysing something is an activity.
Assaying is an activity.
Here "analysing something" relates to a specific item: Inform knows this because it looks for the clue "something" (or "of something") after the activity's name, which in the first case above is simply "analysing".
Creating an activity is like creating an action: it automatically makes new rulebooks - "before analysing", "for analysing" and "after analysing" - but they start out empty, so the activity does nothing yet. Just as it does for rulebooks, Inform defines the adjectives "empty" and "non-empty" for activities to test this state:
if the analysing activity is empty, ...
will be true only when all three of its rulebooks are empty.
Moreover, a newly created activity never happens, unless we take steps to make it do so. We can make an activity happen at any time by writing phrases like so:
carry out the analysing activity with the pitchblende;
carry out the assaying activity;
To make the activity do something useful, we need to put a rule into its "for" rulebook:
The last for assaying rule:
say "Professionally, you cast an eye around mineral deposits nearby, noticing [list of rocks in the location]."
"The last" is a technicality about rulebooks (see the next chapter) which, put briefly, guarantees that this rule comes last among all possible "for assaying" rules. This is good form because the whole point of an activity is to make it easy for further rules to interfere - so we deliberately hang back to last place, giving precedence to anybody else who wants it.
It may look rather pretentious to dress up the footling little "assaying" example as an activity, but it gains us more than might first appear. Every new activity created provides a context which other activities can observe. We could, for instance, define
Rule for printing the name of a rock while assaying: ...
so that during assays more technical names are used.
| ![]() ![]() An Encyclopedia set which treats volumes in the same place as a single object, but can also be split up. |
|
| ![]() ![]() ![]() Modifying the rules for examining a device so that all devices have some specific behavior when switched on, which is described at various times. |
|
| ![]() ![]() ![]() Adding a "printing the description of something" activity. |
|
Previous | Contents | Next |