§3.23. Parts of things
Everything has one and only one kind. This is both good and bad: good for clarity, bad if something needs to behave in two different ways at once. How might we simulate a car with an ignition key, given that no single thing can be both a "vehicle" and a "device" at the same time?
The Inform world model takes the view that such a car is too complicated to be simulated with a single thing. Instead it should be simulated as a vehicle (the car) which has a device (the ignition) attached. This is done using a third kind of containment to those seen so far ("in..." and "on..."): "part of".
The Confectionary Workshop is a room. The Chocolate Machine is here. "The Chocolate Machine has pride of place. A lever and two buttons, one white, the other brown, seem to be the only controls. On top is a hopper."
A container called the hopper is part of the Chocolate Machine. The lever, the white button and the brown button are parts of the Chocolate Machine.
The Chocolatier's desk is here. "The Chocolatier evidently works at the imposing green-leather topped desk facing the Machine. It has three drawers with brass handles."
The upper drawer, the middle drawer and the lower drawer are parts of the desk. The upper drawer, the middle drawer and the lower drawer are openable closed containers. In the middle drawer is a sugared almond. In the lower drawer is a Battenburg cake. On the desk is a liquorice twist.
The cake, the twist and the almond are edible.
The machine and the desk each have several "parts" representing subsidiary pieces of themselves. The desk is a "supporter" (it needs to be, for the liquorice twist to be on top) but also has three "containers" attached, each of which can be opened or closed independently.
In the interests of realism, the standard rules of play protect these composite things. Thus if the desk were to be moved elsewhere (rolling on sugar casters perhaps) then its parts would move with it, and the player is not allowed to detach parts of things: the drawers can be opened or closed, but not pulled out altogether.
Note that rooms and regions are not allowed to have parts. (Rooms are already parts of regions, and to divide up rooms, we can either make several rooms or place containers or other obstacles in a single one.)
It may not be immediately obvious why we might want to create new intermediate categories of the kinds hierarchy. But there may be times, for instance, where we would like to make an action that applies in the same way to both containers and supporters, but to nothing else in the game. To avoid creating two nearly-identical rules, we would instead roll the two categories together into one, on the principle that duplicating source text is usually a sign of bad design.
So for instance let's say the player is able to zap objects to make them go away, but any contents -- things inside a container or on top of a supporter -- should always be left as residue. Here's one way we might do this:
Section 1 - Procedure
An enclosure is a kind of thing. A container is a kind of enclosure. A supporter is a kind of enclosure.
Understand "zap [something]" as zapping. Zapping is an action applying to one thing. The Zapping action has a list of things called the remnants.
Carry out zapping an enclosure:
if the noun holds something:
now the remnants is the list of things held by the noun;
repeat with N running through the remnants:
move N to the holder of the noun.
Carry out zapping:
now the noun is nowhere.
say "You zap [the noun], destroying [them][if the remnants is not empty] and leaving [the remnants with indefinite articles] behind[end if]."
Section 2 - Scenario
SuperDuperMart is a room. SuperDuperMart contains some shelves and a cash register.
The shelves support a bottle of Buffout and a container of Jet.
The cash register contains some prewar money, a coin purse, and a bottle cap. The coin purse contains a prewar nickel. It is closed.
The cash register is closed and locked.
Test me with "zap shelves / zap buffout / zap register / zap purse".
The Shipping Room is a room. The red sticky label is a thing carried by the player. The description of the red sticky label is "It reads: AIRMAIL[if the label is part of something (called the parent)]. It is stuck to [the parent][end if]."
A black crate is in Shipping. The description is "A boring black crate." The brown crate is a thing in Shipping. The description is "An ordinary brown crate."
After examining something when the label is part of the noun:
say "A bright red sticky label is attached to [the noun]!"
Here is the essential point: whenever we ATTACH LABEL TO something, it becomes part of that object.
Instead of tying the red sticky label to something:
now the red sticky label is part of the second noun;
say "You stick [the label] to [the second noun]."
And of course the label cannot be stuck to itself or to more than one thing at a time.
Before tying the label to something when the label is part of something:
if the label is part of the second noun:
say "[The label] is already stuck to [the second noun]." instead;
say "(first freeing the label)[line break]";
silently try taking the label;
if the label is part of something, stop the action.
Instead of tying the red sticky label to the label:
say "That would ruin the label entirely."
Instead of taking the label when the label is part of something:
now the player carries the label;
say "You peel the label off again."
Much of the rest is just tidying to make sure that the player's commands are redirected into the right syntax.
Instead of tying something to the label:
try tying the label to the noun.
Instead of putting the label on something:
try tying the label to the second noun.
Instead of inserting the label into something:
try tying the label to the second noun.
Understand the commands "stick" or "apply" as "tie".
We could have created a new "sticking" action, but to keep the example short we will use the built-in "tying" action instead, and respond to the command "stick" just as if it were "tie".
Understand "peel [something]" or "peel off [something]" as taking.
Test me with "i / put label on the black crate / look / x black / x label / get the label / apply label to brown crate / look / x brown / peel off label / stick label to label".
Disenchantment Bay 12
Include Locksmith by Emily Short.
The Cabin is a room. "The front of the small cabin is entirely occupied with navigational instruments, a radar display, and radios for calling back to shore. Along each side runs a bench with faded blue vinyl cushions[if the compartment is closed], which can be lifted to reveal the storage space underneath[otherwise], one of which is currently lifted to allow access to the storage compartment within[end if]. A glass case against the wall contains several fishing rods.
Scratched windows offer a view of the surrounding bay, and there is a door south to the deck. A sign taped to one wall announces the menu of tours offered by the Yakutat Charter Boat Company."
The Cabin contains a glass case. In the glass case is a collection of fishing rods. Understand "rod" as the collection. The case is closed, transparent, openable, lockable, and locked. The case is scenery. The small silver key unlocks the case.
The bench is in the cabin. On the bench are some blue vinyl cushions. The bench is enterable and scenery. The cushions are scenery.
A storage compartment is an openable closed container. It is part of the bench. Instead of opening the bench, try opening the storage compartment. Instead of closing the bench, try closing the storage compartment. Instead of pushing or pulling or turning the cushions, try opening the storage compartment. Understand "space" as the storage compartment.
Some nets and a Coke are in the compartment. Understand "net" as the nets. The description of the nets is "They must have something to do with fish as well. Really, you're just here for the sights." The nets are a container.
Some navigational instruments, some scratched windows, a radar display, and some radios are scenery in the cabin. The radar, the instruments, and the radios are devices. The radar and the instruments are switched on.
A screen is part of the radar. The description of the screen is "[if the radar is switched on]Phantom lights move across the screen.[otherwise]The screen is dark.[end if]". Instead of doing something other than examining to the screen, say "It's not good for much but looking at."
The Captain is a man in the Cabin. "The captain sits at the wheel, steering the boat and occasionally checking the radar readout." The captain wears a baseball cap. The description of the cap is "It says, THE WORST DAY FISHING IS BETTER THAN THE BEST DAY WORKING." The captain carries the silver key. The description of the captain is "[The captain] is wearing [a list of things worn by the captain][if the captain carries something] and carrying [a list of things carried by the captain][end if]."
The description of the instruments is "Knowing what they do is the Captain's job." Instead of doing something other than examining to the instruments in the presence of the Captain: say "The Captain glares at you. Clearly you are not welcome to do that."
The description of the windows is "They're a bit the worse for wear, but you can still get an impressive view of the glacier through them. There were whales earlier, but they're gone now." Understand "window" as the windows.
The description of the radar is "Apparently necessary to avoid the larger icebergs."
The description of the radios is "With any luck you will not need to radio for help, but it is reassuring that these things are here."
A sign is scenery in the Cabin. The description is "You can get half-day and full-day sight-seeing tours, and half-day and full-day fishing trips."
The view of the Malaspina glacier is a backdrop. It is everywhere. The description is "The Malaspina glacier covers much of the nearby slope, and -- beyond it -- an area as large as Rhode Island." Understand "view of the surrounding bay" or "surrounding bay" as the view.
The cabin door is south of the Cabin and north of the Deck. It is a door and scenery. The description of the Deck is "The whole back half of the boat is open, allowing you to view the surroundings without intervening windows -- if you can stand the cold."
The ice chest is a closed openable container in the Deck. "A very heavy ice chest sits on the ground." It is fixed in place and pushable between rooms.
A quantity of ice is in the Deck. "All around the boat bob chunks of glacier ice." Understand "glacier ice" as the quantity. The description is "Curiously cooled into funny-shaped chunks." The printed name of the quantity is "glacier ice".
Instead of taking the quantity of ice when the player is not carrying the nets:
if the quantity of ice is handled, continue the action;
say "You are having a hard time fishing out the ice with your bare hands."
Instead of taking the quantity of ice when the player is carrying the nets:
if the quantity of ice is handled or the quantity of ice is in the nets, continue the action;
now the quantity of ice is in the nets;
say "You scoop up the ice with the net."
Instead of taking the chest: say "It's too heavy to lift, but you might be able to push it, and just inch it over the frame of the door."
The player is carrying a backpack. The player is wearing a pair of sunglasses. The description of the sunglasses is "The light off the water and the ice does get pretty bright sometimes."
The backpack is a player's holdall. The carrying capacity of the player is 3. The backpack is wearable.
Instead of asking the Captain for the key:
say "'Sure, you can -- well, get me a drink first, would you?'"
Instead of asking the Captain for the key when the Captain is carrying a cold Coke and the Captain is carrying the key:
move the key to the player;
say "'Here, knock yourself out.'"
Instead of asking the Captain for the key when the Captain is not carrying the key: say "'I already gave it to you. You didn't lose it, did you?'"
Heat is a kind of value. The heats are cold, cool, room temperature, and warm.
A beverage is a kind of thing. A beverage can be open or closed. A beverage can be openable or unopenable. A beverage is always edible and openable. A beverage has a heat. A beverage is usually warm. The Coke is a beverage. The beer is a beverage. The beer is in the backpack.
Instead of giving or showing a beer to the Captain:
say "'I don't drink on the job, thanks,' he says. 'You can help yourself if you want it, though.'"
Instead of giving or showing a Coke to the Captain:
say "'It needs chilling,' the Captain remarks, disgruntled."
Instead of giving or showing a cold Coke to the Captain:
move the Coke to the Captain;
increase the score by 2;
say "'Ah, thank you,' he says. How he can drink an iced soda on a day like today is an open question, but Alaskans are special."
Every turn when the quantity of ice is in the ice chest:
repeat with item running through beverages in the ice chest:
let the current heat be the heat of the item;
if the current heat is not cold, now the heat of the item is the heat before the current heat.
Before printing the name of a beverage (called the drink):
say "[heat of the drink] ".
Understand the heat property as describing a beverage.
The maximum score is 5.
After taking the fishing rods:
end the story finally;
increase the score by 3;
say "Success is yours! (Now if only you knew anything about fishing.)"
Test me with "test first / test second / test third".
Test first with "x captain / open case / i / ask captain for the key / give beer to captain / open bench / x nets / get nets / get coke / give coke to captain".
Test second with "s / open chest / drop nets / get glacier ice / get nets / get glacier ice / g / put glacier ice in chest / get coke / put coke in chest".
Test third with "x coke / g / g / g / get coke / n / give coke to captain / ask captain for key / open case / get rods".