| Chapter 12: Advanced Actions |

| 12.9. Check, carry out, report

The normal behaviour of an action is specified by its three associated rulebooks - check, carry out and report. In the case of our "photographing" example, these rulebooks will be:

> Check photographing. Here, for instance, we need to verify that the player has the camera. If any of our checks fail, we should say why and stop the action. If they succeed, we say nothing.

> Carry out photographing. At this stage no further checking is needed (or allowed): the action now definitively takes place. At this point we might, for instance, deduct one from the number of exposures left on the film in the camera, or award the player points for capturing something interesting for posterity. But we should say nothing.

> Report photographing. At this stage no further activity is needed (or allowed): whatever effect the action had, it has happened and is now over. All we can do is to say what has taken place.

So far we have not really gone into the business of what rulebooks are, and we don't do so here either - suffice to say that we can now create whatever rules we need:

> A check photographing rule: if the camera is not carried then say "You can hardly photograph without a camera, now can you?" instead.

In fact, writing "a check photographing rule" is over-formal. We can more simply label our rules like so:

> Check photographing: if we have photographed the noun then say "You've already snapped [the noun]." instead.

> Report photographing: say "Click!"

For the sake of brevity, photography has no interesting consequence (no points to be won, no film to use up), so there are no carry out rules here. Note the way we used the word "instead" once again to stop actions in their tracks.

We can continue to add rules at any point, and a classic thing that happens when testing a new work is that the designer realises there is a case which has not been thought of:

> Check photographing: if the noun is the camera then say "That would require some sort of contraption with mirrors." instead.

162
| Example Waxwork Containers and supporters that report their contents when you EXAMINE them.

163
| Example The Dark Ages Revisited An electric light kind of device which becomes lit when switched on and dark when switched off.

164
| Example Removal TAKE expanded to give responses such as "You take the book from the shelf." or "You pick up the toy from the ground."

It is sometimes useful to add rules to the check and carry out rulebooks to record information that will be useful later in processing the action. For instance, suppose that we want to change the reporting of "take" so that the player is always told something like "You take the book from the shelf." or "You pick up the toy from the ground." In order to generate these reports, we will need to know where the object started, even though by the time we are printing the output, the object will have moved. One possibility is to record a previous location during the "carry out" phase of the action, and then refer to it later during the report phase, so: "Removal" The Pharmacy is a room. A desk and a trash can are in the Pharmacy. The pill-counter, a prescription, and a computer are on the desk. The computer is fixed in place. The pill-counter contains some Vicodin. The trash can contains an empty box. Previous locale is an object that varies. The previous locale could in theory be either a thing or a room, so we make it "an object" -- that is, the most generic possible kind, to which both things and rooms belong. Now we record what the previous locale is at the beginning of each taking action: First carry out taking rule: change the previous locale to the holder of the noun. Saying that this is the first carry out taking rule means that it will be used before any other carry out rules, no matter how specific. This means that we will always capture the locale before moving the object in question. For more about the sequencing of rules, and specifying "first" and "last" rules, see Chapter 17. Report taking something: if the previous locale is the location, say "You pick up [the noun] from the ground."; otherwise say "You take [the noun] from [the previous locale]."; stop the action. Test me with "get all". We "stop the action" here because the report rules are followed in order, and unless we specifically stop, Inform will go on to the default report taking rule, giving us output like You take the box from the freezer. Taken. This is obviously undesirable. We could also say Report taking something: if the previous locale is the location, say "You pick up [the noun] from the ground." instead; otherwise say "You take [the noun] from [the previous locale]." instead. Including "instead" at the end of a say phrase stops the action after the phrase is printed.

165
| Example Paddington A CUT [something] WITH [something] command which acts differently on different types of objects.

Previous | Contents | Next