Inform 7 Home Page / Documentation


§10.2. Liquids

Liquids are notoriously difficult to simulate well. A fully thorough approach consumes endless storage and can be very finicky to write and keep realistic. It is essential to decide what aspect of a liquid's behaviour is actually needed in a given story, and to simulate only that. For instance, if we only need a little chemistry, where a player can add (say) water to salt and make a solution, we do not want to fool around with calculating quantities or concentrations: what's important is that "some water" (amount unspecified) combines with "some salt" to produce "some salty water". We should no more calculate precisely here than we would work out where all the furniture is to the nearest inch. Good advice for handling liquids is to simulate the least amount of realism possible, but no less.

Sometimes all we want is a down-in-one drink: we needn't simulate the actual liquid, just the bottle it comes in, and all we need is to handle the "drinking" action. See Beverage Service, and also 3 AM, where carbonated drinks can be shaken - again simulating the vessel, not the liquid.

Some elementary biochemistry in Xylan is done simply by... well, the point is that two different liquids are represented by single things each, and a chemical reaction simply switches one for the other.

In Frizz, we allow any container to be filled with water (only) and we simulate what happens to any solid objects also inside: some waterproof, some not. Flotation provides a well (always full of water), with rules to determine whether things dropped into it should sink or float.

Next we move up to quantitative approaches, where we remember not just whether a liquid is present, but how much of it. In its simplest form, we could have a drinking vessel from which we draw in sips, so that it can be full, half-empty or empty: see Thirst.

The example with the best compromise between simulation quality and complexity is Lemonade. Here we provide a kind of container called a "fluid container", not just a single cup, and each such vessel has a given "fluid capacity". Each holds only a single liquid at a time (so no mixtures) and can be empty or full to any level (rounded off to the nearest 0.1 fl oz). We can fill one vessel from another (unless it would make a mixture). But liquids leaving these vessels must be consumed - drunk or poured away without trace: we cannot make pools on the floor, or carry liquids in our cupped hands. There is no object representing "lemonade": there are only fluid containers, but which can be called LEMONADE if that is what they now contain.

Savannah is a light elaboration of Lemonade, showing how liquids might be poured on other objects, as for instance to extinguish a fire.

Noisy Cricket extends Lemonade to allow for mixing, though then the number of different possible mixtures is so large that complexity increases greatly. Lakeside Living extends Lemonade differently to add a "liquid source" kind, a form of fluid container which has infinite fluid capacity and is scenery - ideal for a lake, river or spring.

* See Bags, Bottles, Boxes and Safes for stoppered bottles which could also be used for carrying liquids around in

* See Heat for keeping liquids warm in insulated containers


arrow-up.png Start of Chapter 10: Physics: Substances, Ropes, Energy and Weight
arrow-left.png Back to §10.1. Gases
arrow-right.png Onward to §10.3. Dispensers and Supplies of Small Objects

*ExampleThirst
A waterskin that is depleted as the player drinks from it.

*ExampleBeverage Service
A potion that the player can drink.

*ExampleFlotation
Objects that can sink or float in a well, depending on their own properties and the state of the surrounding environment.

**ExampleXylan
Creating a new command that does require an object to be named; and some comments about the choice of vocabulary, in general.

***ExampleFrizz
Liquid flows within containers and soaks objects that are not waterproof; any contact with a wet object can dampen our gloves.

***Example3 AM
A shake command which agitates soda and makes items thump around in boxes.

***ExampleLemonade
Containers for liquid which keep track of how much liquid they are holding and of what kind, and allow quantities to be moved from one container to another.

***ExampleSavannah
Using the liquid implementation demonstrated in Lemonade for putting out fires.

***ExampleNoisy Cricket
Implementing liquids that can be mixed, and the components automatically recognized as matching one recipe or another.

***ExampleLakeside Living
Similar to "Lemonade", but with bodies of liquid that can never be depleted, and some adjustments to the "fill" command so that it will automatically attempt to fill from a large liquid source if possible.