9.8. Simple Machines

| Chapter 9: Props: Food, Clothing, Money, Toys, Books, Electronics |

| 9.8. Simple Machines

The "device" kind provides for the simplest form of machine: one which is, at any given moment, switched on or switched off. Inform looks after this state, but leaves it to us to make the machine actually do something:

> The air-conditioning unit is a device in the Florist's Shop. The air-conditioning is fixed in place and switched on.

> Every turn when in the Florist's Shop:
> if the air-conditioning is switched off, say "You worry about the cut flowers in this jungle-hot air.";
> otherwise say "There is an low susurration from the air-conditioning unit."

One primary dictionary definition for a machine is "an apparatus using or applying mechanical power and having several parts", and we often use the "part of" relationship to build machinery. Control Center provides a neat way to display the component parts of a machine to the player who examines it.

One component almost always part of an electrical machine is the (literal) switch, lever or button to control whether they are switched on or off. In Model Shop just such an on/off button is automatically made part of every device.

While an electrical device has only two states, a mechanical machine might have many, and for these the best approach is to define a kind of value naming the possibilities: see Signs and Portents, where the states are the possible destinations pointed towards.

Perhaps stretching the definition of "machine", What Makes You Tick demonstrates a fishing pole which the player can put together from several pieces.

See Bags, Bottles, Boxes and Safes for a safe that can be dialed to different combinations

61
| Example Control Center Objects which automatically include a description of their component parts whenever they are examined. |
WI

55
| Example Model Shop An "on/off button" which controls whatever device it is part of. |
WI

50
| Example Signs and Portents Signpost that points to various destinations, depending on how the player has turned it. |
WI

416
| Example What Makes You Tick Building a fishing pole from several component parts that the player might put together in any order. |
WI

> Suppose we want to let the player build a fishing pole out of three parts: a hook, a string, and a stick. There are several things we must account for here. One is that our combination verb should be insensitive to ordering: it shouldn't matter whether the player types COMBINE STICK WITH STRING or COMBINE STRING WITH STICK. Second, we need to make sure that our implementation handles intervening stages of assembly gracefully. The player should be able to combine string and hook first, or string and stick first, and be able to complete the assembly in either case. Our implementation here uses a table of lists to determine which combinations of inputs should produce which result object. Because we sort our lists before comparing them, we guarantee that the player's ordering doesn't matter: COMBINE STICK WITH STRING will have the same effect as COMBINE STRING WITH STICK. What's more, our implementation could be expanded to account for many other assemblages, if we wanted object-building to be a running theme of puzzles in our game. "What Makes You Tick" Understand "combine [something] with [something]" as combining it with. Combining it with is an action applying to two carried things. Understand the command "connect" as "combine". Understand the command "attach" as something new. Understand "attach [something] to [something]" as combining it with. The combining it with action has an object called the item built. Setting action variables for combining something with something: let X be a list of objects; add the noun to X; add the second noun to X; sort X; repeat through the Table of Outcome Objects: let Y be the component list entry; sort Y; if X is Y: now the item built is the result entry. Check combining it with: if the item built is nothing or the item built is not in limbo, say "You can't combine [the noun] and [the second noun] into anything useful." instead. Carry out combining it with: move the item built to the holder of the noun; remove the noun from play; remove the second noun from play. Report combining it with: say "You now have [an item built]." Limbo is a container. Limbo contains a hookless fishing pole, a hooked line, and a complete fishing pole. Streamside is a room. The player carries a stick, a wire hook, and a string. Table of Outcome Objects
> component list | result
> {stick, string} | hookless fishing pole
> {wire hook, string} | hooked line
> {hooked line, stick} | complete fishing pole
> {hookless fishing pole, wire hook} | complete fishing pole
Test me with "combine stick with string / i / combine pole with hook / i". This kind of implementation makes sense if we don't intend the player to take the fishing pole apart again, or to refer to any of its component parts once it is built. For an alternate approach that does allow assembled objects to be taken apart again, see "Some Assembly Required".

Previous | Contents | Next