Flotation
Here we want a rulebook to determine whether objects float or sink, so we create an object-based rulebook for the purpose. The more specific rules here, pertaining to corks and to inflated things, will be consulted first; then, as a default, the general flotation rule.
We also want a switch that can turn flotation off at will. The rule about the big switch will be observed before the others because the when… clause makes it more specific than the other rules in the flotation rulebook.
If we wanted, we could also put these rules into a rulebook in an explicit order, overriding Inform's automatic sorting by specificity.
And finally a few description rules to make things look prettier:
As we recall from the chapter on activities, "writing a paragraph about…" is an activity; activities are themselves structured as sets of object-based rulebooks. The activity "writing a paragraph about" uses three object-based rulebooks (before writing…, for writing…, after writing…). We could have made a flotation activity as well, but in general it is overkill to make an activity to make success/failure decisions. For that purpose an object-based rulebook is sufficient.
Test me with "get all / put cork in well / put ring in well / put ingot in well / x well / get cork / get ring / switch switch on / put cork in well / put ring in well / x well / switch switch off / switch switch on".
The chief feature of the room is a concrete-sided well full of water.
A big switch labelled "MAKE EVERYTHING SINK" is mounted on one wall. It is currently switched off and silent.
You can also see a cork, an inflated rubber ring and a lead ingot here.
>(Testing.)
>[1] get all
cork: Taken.
inflated rubber ring: Taken.
lead ingot: Taken.
>[2] put cork in well
The cork bobs on the surface.
>[3] put ring in well
The inflated rubber ring bobs on the surface.
>[4] put ingot in well
The lead ingot sinks out of sight.
>[5] x well
On the surface of the water you can see an inflated rubber ring and a cork.
>[6] get cork
Taken.
>[7] get ring
Taken.
>[8] switch switch on
You switch the big switch on.
>[9] put cork in well
The cork sinks out of sight.
>[10] put ring in well
The inflated rubber ring sinks out of sight.
>[11] x well
There is nothing on the surface of the water, nor can you see into the depths.
>[12] switch switch off
You switch the big switch off.
The inflated rubber ring and the cork rise to the surface of the well.
>[13] switch switch on
You switch the big switch on.
The inflated rubber ring and the cork sink out of sight.