Inform 7 Home Page / Documentation
§10.10. Magic (Breaking the Laws of Physics)
Every previous section of this chapter has been about adding further realism constraints to Inform, to give it a more advanced understanding of physics (and chemistry). But Inform has plenty of physical laws built into it already, even if they are more mundane: inanimate objects do not spontaneously move or change, one solid object cannot pass through another, there are opaque barriers through which light cannot pass, and so on. These rules stop many attempted actions. (GO EAST - "The oak door is closed." GET EMERALD - "You can't, since the glass display case is in the way.")
In the real world, physics is not negotiable. ("Gravity: it's not just a good idea, it's the law.") But in stories, magic can sometimes happen, and in these examples some of the rules built into Inform are waived in special circumstances, which in effect cancel certain physical laws. Very many other magical tricks could be achieved: if you want to make a given command work despite realism constraints, try typing ACTIONS - a testing command which reveals what is happening behind the scenes - and then typing the command you want. This should reveal which named rule is stopping it: you can then try suspending that rule, and seeing if the effect now works.
See Magic Words for ways to create new single-word spell commands
|Start of Chapter 10: Physics: Substances, Ropes, Energy and Weight|
|Back to §10.9. Heat|
|Onward to §10.11. Mathematics|
The School for Gifted Youngsters is a room. Kitty Pryde is a woman in the School for Gifted Youngsters. "Kitty Pryde waits for you to say why you summoned her out of class." The description is "You see nothing special about Kitty Pryde. But that is only because she has learned to conceal her mutant powers: in fact she has the alternative name Shadowcat, and the ability to phase through solid objects."
The glass box is a container in the School for Gifted Youngsters. It is closed, openable, and transparent. In the box is a quantity of poisonous gas. In the box is a thing called the message from Magneto.
Instead of examining the message when the player is not carrying the message:
say "You'd need to be holding it before you could read it."
Instead of opening the glass box: say "You're deterred by the swirling bottle-green mist within."
Check someone taking the gas (this is the gaseous object rule): rule fails.
Unsuccessful attempt by someone taking the gas: say "The gas isn't something one can pick up in one's bare hands."
if the player can touch the gas:
say "The gas has reached your lungs!";
end the story.
A rule for reaching inside something:
if the person reaching is Kitty, allow access.
Persuasion rule for asking someone to try doing something: persuasion succeeds.
Test me with "get message / kitty, get message / open box / kitty, open box".
Now the player can get Kitty to take the message without releasing the poisonous gas:
Kitty Pride waits for you to tell her why you summoned her out of class.
You can also see a glass box (closed) (in which are some poisonous gas and a message from Magneto) here.
>kitty, get message
Kitty Pryde picks up a message from Magneto.
Instead of waving the X-Ray Vision Wand:
say "Disappointingly, nothing happens."
Instead of waving the X-Ray Vision Wand when the player can see someone who is concealing something:
say "The wand glows green. Immediately you see on the monitor [a list of things which are concealed by people who can be seen by the player]."
After printing the name of a thing (called target) which is carried by someone while waving the wand:
say " (carried by [a random person who carries the target])"
The Interrogation Chamber is a room. "Despite its gothic name, this room is a rather civilized place for your work, with large plate-glass windows and a fitted carpet."
A thing can be secret or obvious. A thing is usually obvious.
Brian is in the Interrogation Chamber."Brian lounges against the wall." Brian carries a quantity of plastic explosive. The explosive is secret.
Janine is in the Interrogation Chamber. "Janine toys nervously with a laptop bag." Janine carries a chocolate biscuit, a laptop bag, and a microfilm. The microfilm is secret. The laptop bag is wearable. In the bag is a laptop computer.
Rule for deciding the concealed possessions of something: if the particular possession is secret, yes; otherwise no.
Instead of examining someone: say "[The noun] is openly carrying [a list of unconcealed things carried by the noun]."
Suppose we want to have a machine in our game that can transmute one item into another, similar object with different properties: a bag of jelly beans into a bag of jewels, for instance. Thus each item will be associated with some number of equivalents -- the other objects it can turn into. This is a handy use for group relations:
Transmutation relates things to each other in groups. The verb to become means the transmutation relation.
Definition: a thing is transmutable if it becomes more than one thing. [* It always becomes itself.]
A thing can be valuable. Something valuable called a bag of jewels is carried by the player. It becomes the bag of gunpowder and the bag of jelly beans.
A thing can be dangerous. The bag of gunpowder is a dangerous thing.
The can't insert into what's not a container rule does nothing when inserting something into the machine.
Check inserting something which is not transmutable into the machine:
instead say "You can't transmute that."
To decide which thing is new form of (obj - edible thing): decide on a random valuable thing which becomes obj.
To decide which thing is new form of (obj - dangerous thing): decide on a random edible thing which becomes obj.
To decide which thing is new form of (obj - valuable thing): decide on a random dangerous thing which becomes obj.
Carry out inserting something into the machine:
now the noun is nowhere;
now the player carries the new form of the noun.
Report inserting something edible into the machine:
say "The machine clicks, whirrs, and spits out [a new form of the noun]. You're rich!";
Report inserting something dangerous into the machine:
say "The machine clicks, whirrs, and in a shower of flavor crystals, spits out [a new form of the noun].";
Report inserting something valuable into the machine:
say "The machine clicks, whirrs, and with a violent roar, spits out [a new form of the noun].";
Test me with "i / put jewels in machine / i / put gunpowder in machine / i / put beans in machine".
In this example we have only defined a single set of transmutable objects, but we could easily expand to include other groups.
(Thanks to Jesse McGrew for proposing this example.)
Access All Areas
If somebody tries to walk through a closed door, the "can't go through closed doors rule" usually stops them. This is a rule belonging to the "check going" rulebook. These names are fairly explanatory when written out, but hard to remember: fortunately we don't need to remember them, as the Index panel contains a full inventory of the check, carry out and report rules for every action, showing all of their names and the order in which they are checked. (We can also find out which rules are stopping an action by typing the testing command ACTIONS.)
Here we make the rule do nothing provided a condition holds:
The extremely difficult door is north of the Standing Room and south of the Room of Walking Upside Down. It is a locked door.
The player is carrying the Pointy Hat of Liminal Transgression. The hat is wearable.
The can't go through closed doors rule does nothing when the Hat is worn.
(The Pointy Hat may be useful in debugging a game, even if it never makes it into the final published work.)