1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00
inform7/resources/Documentation/Examples/FalloutEnclosure.txt
2019-03-16 13:12:11 +00:00

40 lines
2 KiB
Plaintext

*** Parts of things
(Containers and supporters given a common kind; Fallout Enclosure)
Adding an enclosure kind that includes both containers and supporters in order to simplify text that would apply to both.
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:
{*}"Fallout Enclosure"
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.
Report zapping:
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".