Liquids by Xavid


This extension provides basic support for sources of liquids and things that can hold a liquid. It has some similarities to Liquid Handling by Al Golden but restricts itself to pretty basic functionality, not addressing possibilities like mixing liquids and interactions between liquids and other objects. It also isn't interested in measuring volumes of liquid.

Chapter 1 - Vessels and Water-Tight Things

A thing can be water-tight, which means it can hold a liquid. A vessel is a kind of thing that is water-tight, but you can also declare things water-tight directly, for example if you want a water-tight container (that can hold both liquids and things).

A water-tight thing has a property called the contained liquid. Thus, you can create a vessel full of water with:

A vessel called a bottle is here. The contained liquid is water.

Liquids are a kind of enumerated value, rather than a thing. (The water in two different things is equivalent, rather than them being two separate objects.) You can't interact with the liquid directly, but with whatever it's in. (However, you can use the contained liquid to refer to the thing it's in.)

If there's nothing currently in a water-tight thing, its contained liquid is the special "liquid" emptiness. Aside from emptiness, the only default liquid is water, but you can easily create new liquids with something like:

There is a liquid called milk.

Water-tight things are considered empty or nonempty based on whether they contain a liquid. You can also refer to them with phrases like "if the noun is full of water" or "if water fills the noun".

Chapter 2 - Liquid-Yielding Things

Sometimes you want to have something be an infinite source of a liquid. To do this, just set the available liquid property of it.

A thing called the fountain is here. The available liquid is water.

You can fill containers at these liquid-yielding things freely.

Such things are considered liquid-yielding, and you can refer to them with phrases like "if the noun yields water" or "if water is available at the noun".

Chapter 3 - Actions

This extension defines only a few basic actions to do with liquids, with the expectation that individual games will probably want to add more depending on how they want liquids to be used.

You can fill a water-tight thing from a liquid-yielding thing or from another water-tight thing. (In the latter case, the source thing will now be empty, because it's assumed that all water-tight things have equivalent capacities.)

You can pour out a water-tight thing, in which case the contained liquid is lost.

You can pour a water-tight thing onto something specific. By default, this is blocked by the block pouring onto rule.

You can also drink from a water-tight thing. The default behavior assumes that liquids are safe to drink and have no side-effects.

Chapter 4 - Bugs and Comments

This extension is hosted in Github at https://github.com/i7/extensions/tree/master/Xavid. Feel free to email me at extensions@xavid.us with questions, comments, bug reports, suggestions, or improvements.

Example: * Kitchen - Basic manipulation of liquids.

"Kitchen"

Include Liquids by Xavid.

Kitchen is a room.

There is a liquid called milk.

A sink is here. It is fixed in place. The available liquid is water.

A vessel called a cup is here.

A vessel called a jug is here. The contained liquid is milk.

Test me with "pour milk into cup / i / drink milk / fill cup from sink / i / empty cup / i".

Example: ** Unit Tests

"Unit Tests"

Include Liquids by Xavid.
Include Command Unit Testing by Xavid.

Kitchen is a room.

There is a liquid called milk.
There is a liquid called juice.
There is a liquid called vinegar.

A sink is here. It is fixed in place. The available liquid is water.

A vessel called a mug is here.

A thing called a big jug is here. The available liquid is milk.

A vessel called a cup is here. The contained liquid is juice.

A closed water-tight openable container called a jar is here. The contained liquid is vinegar.

An animal called a weasel is here.

Unit test:
     start test "implicit taking";
     assert that "fill mug from jug" produces "(first taking the big jug)[line break](first taking the mug)[line break]You pour some milk from the big jug into the mug.";
     do "drop mug";
     assert that "empty mug" produces "(first taking the mug)[line break]You pour out the milk from the mug.";
     do "drop all";
     assert that "fill mug from cup" produces "(first taking the cup)[line break](first taking the mug)[line break]You pour the juice from the cup into the mug.";
     do "drop mug";
     assert that "drink juice" produces "(first taking the mug)[line break]You drink the juice from the mug.";
     do "drop all";
     assert that "fill cup from sink" produces "(first taking the cup)[line break]You fill the cup with water from the sink.";
     assert that "put water in mug" produces "(first taking the mug)[line break]You pour the water from the cup into the mug.";
     assert that "douse weasel" produces "(with the mug)[line break]Drenching the weasel in water doesn't seem like it would improve the situation.";
     assert that "dump mug on weasel" produces "Drenching the weasel in water doesn't seem like it would improve the situation.";
     assert that "dump cup on weasel" produces "The cup doesn't have anything in it to pour out.";
     assert that "empty juice from mug" produces "The mug is full of water, not juice.";
     assert that "empty water from mug" produces "You pour out the water from the mug.";
     assert that "remove juice from mug" produces "The mug doesn't have any juice in it to pour out.";
     do "take jar";
     assert that "empty jar" produces "The jar is closed.";
     assert that "pour jar into cup" produces "The jar is closed.";
     do "fill mug from sink";
     assert that "pour mug into jar" produces "The jar is closed.";

Test me with "unit".