Inform 7 Home Page / Documentation
§13.10. Defining new prepositions
The term preposition is used here, a little loosely, to mean anything which we add to the verb to be in order to talk about some relation or other. We have seen many examples already, such as:
To be in - The ball is in the box.
To be part of - The lever is part of the slot machine.
These are defined just the way verbs are. Compare the following:
The result of this is that
Hercule Poirot suspects Colonel Hotchkiss.
Hercule Poirot is suspicious of Colonel Hotchkiss.
are exactly equivalent, and so are these two descriptions:
somebody who suspects Colonel Hotchkiss
somebody suspicious of Colonel Hotchkiss
While most prepositions are short ("in", "part of", "suspicious of"), they're free to be longer if need be ("inordinately far away from"): the limit is 30 words, which should be ample.
We can also define verbs as auxiliaries, like so:
The verb to be able to approach means the approachability relation.
Now we can ask if Poirot "can approach" Hotchkiss, and so on.
Start of Chapter 13: Relations | |
Back to §13.9. Defining new assertion verbs | |
Onward to §13.11. Indirect relations |
ExampleThe Abolition of Love |
Suppose we are modeling a complex society seething with interpersonal relations of every kind.
The Chapel is a room. Elizabeth, Wickham and Darcy are people in the Chapel. Mr Bennett and Mrs Bennett are people in the Chapel. Georgiana is a person in the Chapel.
Elizabeth loves Darcy. Elizabeth fancies Darcy. Elizabeth notices Darcy. Elizabeth impresses Darcy.
Mr Bennett is related to Mrs Bennett and Elizabeth. Mr Bennett is married to Mrs Bennett.
Now we want ways to set and unset all of these relations. (In the interests of thoroughness, we may get a bit far-fetched here. It is not recommended in practice that we make the player guess the verb "traduce".)
Understand "infatuate [someone] with [someone]" as infatuating it with. Infatuating it with is an action applying to two visible things.
Carry out infatuating it with:
now the noun loves the second noun.
Report infatuating it with:
say "Now [the noun] loves [a random person loved by the noun][if the second noun loves someone], while [the second noun] loves [a random person loved by the second noun][end if]."
Understand "embitter [someone] toward [someone]" as embittering it toward. Embittering it toward is an action applying to two visible things.
Carry out embittering it toward:
now the noun does not love the second noun.
Report embittering it toward:
say "[The noun] sees [the second noun] in a different light and no longer feels any affection."
Because love is a 1-1 relation, a person cannot love more than one other character at a time. Whenever we set a character to love a new person, that person ceases to love the character loved before. It is a fickle world.
One to various relations are a bit more open: we can say someone impresses multiple other characters, and our additions to the list do not override the initial ones.
Understand "commend [someone] to [someone]" as commending it to. Commending it to is an action applying to two visible things.
Carry out commending it to:
now the noun impresses the second noun.
Report commending it to:
say "[The second noun] takes a very decided interest in [the noun]."
Understand "traduce [someone] to [someone]" as traducing it to. Traducing it to is an action applying to two visible things.
Carry out traducing it to:
now the noun does not impress the second noun.
Report traducing it to:
say "[The second noun], hearing your story, decides not to be at all impressed with [the noun]."
And because this is a one-to-various relation, we can also make statements which set multiple relations at once, so:
Understand "celebrate [someone]" as celebrating. Celebrating is an action applying to one visible thing.
Report celebrating:
say "[The list of people who are impressed by the noun] take a very decided interest in [the noun]."
Understand "slander [someone]" as slandering to. Slandering to is an action applying to one visible thing.
Carry out slandering to:
now every person is not impressed by the noun.
Report slandering to:
say "Now [the noun] impresses [the list of people who are impressed by the noun]."
Note that the above unsetting is not equivalent to "now the noun does not impress every person" -- which would be ambiguous in spoken English, as well. Various-to-one relations are similar:
Understand "draw the attention of [someone] to [someone]" as drawing the attention of it to. Drawing the attention of it to is an action applying to two visible things.
Carry out drawing the attention of it to:
now the noun notices the second noun.
Report drawing the attention of it to:
say "[The noun] glances thoughtfully in the direction of [the second noun]."
Understand "distract [someone] from [someone]" as distracting it from. Distracting it from is an action applying to two visible things.
Carry out distracting it from:
now the noun does not notice the second noun.
Report distracting it from:
say "You distract [the noun] from [the second noun]."
Understand "draw attention to [someone]" as drawing attention to. Drawing attention to is an action applying to one visible thing.
Carry out drawing attention to:
now every person notices the noun.
Report drawing attention to:
say "You quickly cause everyone to attend to [the noun]."
Understand "outshine [someone]" as outshining. Outshining is an action applying to one visible thing.
Carry out outshining:
now every person does not notice the noun.
Report outshining:
say "You quickly distract everyone from [the noun]."
Understand "flatter [someone]" as flattering. Flattering is an action applying to one thing.
Report flattering:
say "You draw down universal admiration for [the noun] by casting him or her in a flattering light."
Understand "unflatter [someone]" as unflattering. [Okay, okay, but it's four am.] Unflattering is an action applying to one thing.
Carry out unflattering:
now every person does not fancy the noun.
Report unflattering:
say "[The noun] gives everyone a universal disgust."
Understand "admire [someone]" as admiring. Admiring is an action applying to one thing.
Report admiring: say "You find you rather fancy [the noun]."
Understand "loathe [someone]" as loathing. Loathing is an action applying to one thing.
Understand "cause chaos" as causing chaos. Causing chaos is an action applying to nothing.
Carry out causing chaos:
now every person fancies every person.
Report causing chaos: say "Now everyone fancies everyone else, which is quite an inconvenient state of affairs."
Understand "relieve chaos" as relieving chaos. Relieving chaos is an action applying to nothing.
Carry out relieving chaos:
now every person is fancied by no one.
Report relieving chaos: say "Now no one fancies anyone, which is safe but tedious."
Our options for setting and unsetting symmetrical relations are more limited again:
Section 6 - Setting and Unsetting Marriage (1-1 Symmetrical)
Understand "marry [someone] to [someone]" as uniting it in matrimony with. Uniting it in matrimony with is an action applying to two visible things.
Carry out uniting it in matrimony with:
now the noun is married to the second noun.
Report uniting it in matrimony with:
say "You perform the marriage of [the noun] to [the second noun], joining them to the family of [a list of people related to the noun]."
Understand "divorce [someone] from [someone]" as divorcing it from. Divorcing it from is an action applying to two visible things.
Check divorcing it from:
if the noun is not married to the second noun, say "[The noun] is not married to [the second noun] anyway." instead.
Carry out divorcing it from:
now the noun is not married to the second noun.
Report divorcing it from:
say "[The noun] is now not married to [the second noun]."
When we unset the symmetrical relation on one side, it is automatically set or unset on the other. It is not necessary to say "the second noun is married to the noun" or "the second noun is not married to the noun", even though that is the case.
Section 7 - Setting and Unsetting Acquaintance (V-V Symmetrical)
Understand "introduce [someone] to [someone]" as introducing it to. Introducing it to is an action applying to two visible things.
Carry out introducing it to:
now the noun knows the second noun.
Report introducing it to:
say "You introduce [the noun] to [the second noun]. Now [the noun] is acquainted with [the list of people who are known by the noun], and [the second noun] is acquainted with [the list of people who are known by the second noun]."
Understand "announce [someone]" as announcing. Announcing is an action applying to one visible thing.
Report announcing:
say "You announce [the noun] to the whole assembled company."
Understand "ostracise [someone]" as ostracising. Ostracising is an action applying to one visible thing.
Carry out ostracising:
now every person does not know the noun.
Report ostracising:
say "You cause everyone present to forget and pretend not to be acquainted at all with [the noun]."
And finally, setting groups:
Section 8 - Setting and Unsetting Familial Relations (Groups)
Understand "make [someone] adopt [someone]" as forcing it to adopt. Forcing it to adopt is an action applying to two visible things.
Carry out forcing it to adopt:
now the noun is related to the second noun.
Report forcing it to adopt:
say "Now [the second noun] is related to [the list of people related to the second noun]."
Understand "make [someone] disown [someone]" as forcing it to disown. Forcing it to disown is an action applying to two visible things.
Carry out forcing it to disown:
now the second noun is not related to the noun.
Report forcing it to disown:
say "Now [the second noun] is related to [the list of people who are related to the second noun], and [the noun] is related to [the list of people who are related to the noun]."
Notice that when we say "the second noun is not related", we remove that person from the group: they are now in a separate group of their own, while the rest of the group's members remain related to one another.
And finally, a long litany of test cases, complete with the relations lists:
Test acquaintance with "relations / introduce darcy to elizabeth / introduce darcy to wickham / announce mr bennett / relations / ostracise wickham / introduce georgiana to wickham / relations".
Test impression with "commend georgiana to elizabeth / relations / celebrate Mrs bennett / relations / traduce mrs bennett to darcy / relations / slander mrs bennett / relations".
Test notice with "draw the attention of darcy to elizabeth / relations / draw attention to mr bennett / relations / distract darcy from mr bennett / relations / outshine mr bennett / relations".
Test love with "embitter elizabeth toward darcy / relations / infatuate elizabeth with wickham / relations".
Test marriage with "marry elizabeth to darcy / relations / divorce elizabeth from darcy / relations".
Test alliance with "make mr bennett adopt georgiana / relations / make mrs bennett disown georgiana / relations".
Test fancying with "admire elizabeth / relations / loathe elizabeth / relations / flatter elizabeth / relations / unflatter elizabeth / relations / cause chaos / relations / relieve chaos / relations".
Test me with "test acquaintance / test impression / test notice / test love / test alliance / test fancying / test marriage".
ExampleSwerve left? Swerve right? Or think about it and die? |
Suppose we have marbles that roll downhill across our map, in a life-size version of one of those marble-chute toys. We might now want to keep track of both compass relationships and which-room-slopes-into-which, so we make a new relation:
A thing can be spherical or lumpy. A marble is a kind of thing. A marble is always spherical. The player carries a marble called a red marble. The player carries a marble called an agate marble. The player carries a marble called a blue cloudy marble.
The Long Yellow Slide is north of the Funnel. The Long Yellow Slide overlooks the Blue Funnel. The Ski-jump is below the Blue Funnel. The Blue Funnel overlooks the Ski-jump. The Ski-jump overlooks the Landing Bowl. The Landing Bowl overlooks the Snake Run. The Landing Bowl is north of the Snake Run. The Snake Run overlooks the Goal. The Snake Run is north of the Goal.
And let's say we want the player to be allowed to slide, too, since that would be much more fun than just watching the marbles go:
Understand "sit" as sitting down. Sitting down is an action applying to nothing. Check sitting down: if the player is spherical, say "You are already seated." Carry out sitting down: now the player is spherical. Report sitting down: say "You sit, ready to slide wherever fate takes you."
Understand "stand" or "stand up" as standing up. Standing up is an action applying to nothing. Check standing up: if the player is lumpy, say "You are already standing." Carry out standing up: now the player is lumpy. Report standing up: say "You get to your feet."
Now a rule to control what happens to all our sliding and rolling objects:
Every turn:
repeat with item running through spherical things which are in sloping rooms:
let the current space be the holder of the item;
let the final space be a random room which is overlooked by the current space;
if the player can see the item and the item is a marble, say "[The item] rolls out of the room toward [the final space].[line break]";
if the player is the item, say "You keep sliding...";
move the item to the final space;
if the player can see the item and the item is a marble, say "[The item] rolls into the room from [the current space].[line break]".
Since the Ski-jump overlooks the Landing Bowl, the marble will be able to fly through the air to its destination, even though there is no map connection to allow the player to cross. We might want to let the player make it across this barrier also, so:
Instead of jumping in a sloping room:
say "You leap...";
move the player to a random room overlooked by the location.
Because overlooking is various-to-various, we could include that element popular in marble chute toys, the splitter:
The Downhill Splitter is north of the Long Yellow Slide. "The green plastic chute runs downhill towards a Y-junction, forcing incoming marbles right or left."
The Downhill Splitter overlooks the Long Yellow Slide and the Purple Snaking Passage. The Purple Snaking Passage is southeast of the Downhill Splitter. The Purple Snaking Passage overlooks the Landing Bowl. The Purple Snaking Passage is above the Landing Bowl.
Test me with "drop red / drop blue / sit / z / stand up / drop agate / sit / z / z / z / z / z".
ExampleBeneath the Surface |
The standard world model provides for the idea of containers and supporters, but this is not the only way that objects can relate to one another in the real world. Here we try adding the idea of concealment beneath another object:
Underlying relates various things to one thing. The verb to underlie means the underlying relation. The verb to be under means the underlying relation. The verb to be beneath means the underlying relation.
Instead of looking under a thing which is underlaid by something (called the lost object):
say "You find [the list of things which underlie the noun]!";
now every thing which underlies the noun is carried by the player;
now every thing which underlies the noun does not underlie the noun.
Hiding it under is an action applying to one carried thing and one thing. Understand "put [something preferably held] under [something]" as hiding it under. Understand "hide [something preferably held] under [something]" as hiding it under. Understand the commands "shove" and "conceal" and "stick" as "hide".
Check hiding it under:
if the second noun is not fixed in place, say "[The second noun] wouldn't be a very effective place of concealment." instead.
Carry out hiding it under:
now the noun is nowhere;
now the noun underlies the second noun.
Report hiding it under:
say "You shove [the noun] out of sight beneath [the second noun]."
The Room of Hidden Objects is a room. It contains a sofa, an easy chair, and a rug. The sofa supports a lime-green pillow and an innocent-looking Chinese finger toy. The rug is fixed in place. The chair is a supporter.
A treasure map underlies the easy chair. A skeleton is beneath the sofa. A blueprint of Atlantis, a lexicon of Linear A, and the key to Jimmy Hoffa's Mausoleum are under the rug.
Test me with "look under the sofa / look under the rug / look under the easy chair / hide lexicon under rug".
ExampleBogart |
We have two things to keep track of with our layering clothing: what currently is covering something else; and what can cover something else. This implementation goes for a fairly simple treatment, assuming that each item of clothing will completely conceal those beneath it, and that we are not implementing entire sets of shirts, jackets, etc. But it will do for a demonstration.
First we make our relation to represent what *is* underneath another item:
Underlying relates one thing to various things. The verb to underlie means the underlying relation. The verb to be under implies the underlying relation.
And now we prevent taking a lower layer off before the thing that is worn over it:
Before taking off something which underlies something (called the impediment) which is worn by the player:
say "(first removing [the impediment])[command clarification break]";
silently try taking off the impediment;
if the noun underlies something which is worn by the player, stop the action.
Check taking off:
if the noun underlies something (called the impediment) which is worn by the player, say "[The impediment] [are] in the way." instead.
Carry out taking off:
now the noun is not underlaid by anything.
Report taking off something:
say "[We] [are] now wearing [a list of uppermost things worn by the player]." instead.
Definition: a thing is uppermost if it is not under something.
That covers order of clothing removal, but we also want to restrict what can be worn on top of what else. This time we need Inform to have some idea of what customarily can be layered on top of what other clothing:
Overlying relates one thing to various things. The verb to overlie means the overlying relation.
Covering relates a thing (called A) to a thing (called B) when the number of steps via the overlying relation from A to B is greater than 0. The verb to cover means the covering relation.
With these definitions, we can say that a jacket should go over a shirt and a shirt over an undershirt (say), and then Inform will know that a jacket will cover both shirt and undershirt.
Before wearing something when something (called the impediment) which covers the noun is worn by the player:
while the player wears something which covers the noun:
say "(first removing [the impediment])[command clarification break]";
silently try taking off the impediment;
if the player is wearing the impediment, stop the action.
Carry out wearing:
if the noun covers something (called the hidden item) worn by the player, now the hidden item underlies the noun.
Instead of looking under something which is worn by the player:
if something (called the underwear) underlies the noun, say "[We] [peek] at [the underwear]. Yup, still there.";
otherwise say "Just [us] in there."
Instead of taking inventory:
say "[if the player carries something][We]['re] carrying [a list of things carried by the player][else][We]['re] empty-handed[end if][if the player wears something]. [We] [are] wearing [a list of uppermost things worn by the player][end if]."
Notice that our inventory only describes the things that the player can see as the upper layer of clothing.
The Trailer is a room. "A full-length mirror is the main amenity in here, and that suits you just fine." The full-length mirror is scenery in the Trailer. Instead of examining or searching the mirror, try taking inventory.
The player wears a fedora, a jacket, a shirt, some undershorts, an undershirt, some slacks, a pair of socks, and a pair of shoes.
The shirt underlies the jacket. The pair of socks underlies the pair of shoes. The undershorts underlie the slacks. The undershirt underlies the shirt.
The jacket overlies the shirt. The shoes overlie the socks. The slacks overlie the undershorts. The shirt overlies the undershirt.
Test me with "x mirror / remove fedora / remove jacket / remove shirt / remove slacks / remove undershirt / remove shoes / remove socks / remove shorts / remove undershorts".
If we further wanted to prevent the player from taking off clothes in inappropriate places, we might add something like this:
Instead of taking off something in the presence of someone who is not the player:
say "[We] [are] far too modest to strip in public."