💾 Archived View for gemini.ctrl-c.club › ~nttp › writing › intfic › inform7-review.html captured on 2024-08-31 at 14:39:27.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

<!DOCTYPE html>
<meta charset="utf-8">
<title>Test-driving Inform 7</title>
<link rel="stylesheet" type="text/css" href="diary.css">
<link rel="icon" type="image/png" href="icon.png">
<link rel="canonical" href="https://notimetoplay.org/engines/inform7-review.html">
<meta name="viewport" content="width=device-width">
<meta name="description" content="A computer should never, ever try to second-guess a human being. Give me a real programming language.">
<meta name="author" content="Felix Pleşoianu">
<meta property="og:site_name" content="Fictionally interactive">
<meta property="og:type" content="website">

<header role="banner">
 <a href="https://felix.plesoianu.ro/intfic/">Fictionally interactive</a>
 <h1>Test-driving Inform 7</h1>
</header>

<time>19 March 2011</time>

<p>I mention interactive fiction quite often in my articles, but the truth is, I am no longer familiar with the state of the art. Back when I was still serious about writing text adventures, <a href="http://inform7.com/">Inform 7</a> was in alpha and TADS 3 was in beta. Nowadays the two have effectively replaced older systems, and being familiar with them can be useful even if you don't care about IF as an art form:</p>

<ul>
 <li>Interactive fiction has multiple applications in academia, from educational games to teaching people how to program computers in a less intimidating way.</li>
 <li>Interactive fiction is an excellent prototyping tool for more technologically sophisticated game genres such as computer RPGs.</li>
</ul>

<p>Now, I am superficially familiar with the syntax of both, from <a href="http://www.firthworks.com/roger/cloak/">Cloak of Darkness</a>, as well as from skimming the official manuals. But I wanted a closer look and, as it happens, I have just the thing.</p>

<p>Last year I wrote a <a href="https://notimetoplay.org/engines/jaiffa/">toy authoring system</a> in Javascript, and a demo game to go with it. While tiny &mdash; it can be completed in about 85 moves with perfect knowledge &mdash; <i>Catch That Cat</i> does have nine locations, a couple of NPCs and a handful of puzzles. Enough that porting it will be easy, but not trivial. As for the target, I started with Inform 7, simply because it has a Fedora 14 package.</p>

<p>I must admit cheating a little here: I already had some idea of how the language is supposed to work. Enough to try this for a start:</p>

<blockquote><p>The Living Room is south of the balcony, southeast of the kitchen and east of the hallway. "This is you one-room apartment in eastern Bucharest." </p></blockquote>

<p>To my great delight, it worked on first try, creating four rooms and describing the starting one. But wait... it's a bit difficult to navigate. Jaiffa lists exits automatically, but Inform 7 doesn't. A quick trip to the <a href="http://inform7.com/write/extensions/">extension repository</a> yielded <a href="http://inform7.com/extensions/Gavin%20Lambert/Exit%20Lister/index.html">Gavin Lambert's Exit Lister</a>. It doesn't do exactly what I want (the PC should know a-priori where exits lead in this game) but it's a good start.</p>

<p>Now that I have map building figured out, let's see about things.</p>

<blockquote><p>The remote control and the empty beer bottle are on the coffee table.</p></blockquote>

<p>Again, this was accepted immediately but... the items in question were nowhere to be seen. Looking in Index&rarr;World gave me the answer (and proved that Inform really is designed to be used with its GUI): I had just defined a bunch of out-of-play objects. The easy fix was to add <code>The coffee table is here.</code> to the code. As a nice touch, making the table a supporter (implicitly) also nailed it in place. Also note that all rooms are lit by default, as they should be. <em>Perfect.</em></p>

<p>The next one wasn't as straightforward.</p>

<blockquote><p> The TV set is here. "Unfortunately, it's broken. Again." It is fixed in place. It is a device. Instead of switching on the TV: say the description of the TV. </p></blockquote>

<p>Sure, skimming through the manual allowed me to declare it a device, and to handle "switch on" correctly, but now its description appeared in the room, and looking at it gave me a blank line. Turns out, I had set its initial string instead. The fix was trivial:</p>

<blockquote><p> The TV set is here. <em>The description is</em> "Unfortunately, it's broken. Again." It is fixed in place. It is a device. Instead of switching on the TV: say the description of the TV. </p></blockquote>

<p>Now, to allow the player to watch some TV, or rather try to.</p>

<blockquote><p> Watching is an action applying to one visible thing and requiring light. Understand "watch [something]" as watching. Carry out watching: try examining the noun.</p>

<p>Instead of watching TV: say "You look at the blank TV screen for a while. It's actually better than most channels."</p></blockquote>

<p>Trouble is, no matter what I tried, "watch tv" always had the effect of examining it, as if my override didn't exist at all. Can you guess what I was doing wrong? Keep in mind, at this point I had been using Inform 7 seriously for only one hour; surely I was missing something obvious! Sure enough, after playing with other features of the system (and marveling at how you can include a help menu with a single line of code, or release a version playable online with a mouse click), and a little nap too, I figured it out: the verb "watch" already exists as a synonym for "examine". <a href="http://inform7.com/learn/man/doc262.html">Chapter 16, section 3</a> of the manual gave me the solution: <code>Understand the command watch as something new.</code></p>

<p>There are details I left out in the first room, such as the couch (<code>The couch is here. It is an enterable supporter.</code>) and descriptions for the remote/bottle. I also omitted the header line so far &mdash; <code>"Catch That Cat" by "Felix Plesoianu".</code> &mdash; simply because Inform 7 allows me to get away with it. Adding all that might just bring my Inform 7 code at the length of the original:</p>

<pre><code class="javascript">
s = story("Catch that cat");
s.author = "Felix Pleşoianu";

current(room(
	"Living room",
	"This is you one-room apartment in eastern Bucharest."));
tv = thing("TV set", "Unfortunately, it's broken. Again.");
thing("couch").$use = thing("couch").$sit_on =
	"You rest on the couch for a few moments. Aah, comfy!";
thing("coffee table");
thing("remote control").is("portable");
bottle = thing("beer bottle", "It's empty and sad.").is("portable");

exit("North to balcony").altname("n").to(room("Balcony"));
exit("Northwest to kitchen").altname("nw").to(room("Kitchen"));
exit("West to hallway").altname("w", "out").to(room("Hallway"));

tv.$turn_on = tv.$switch_on = tv.$use = tv.description;
tv.$turn_off = tv.$switch_off = "It's already very much off.";
tv.$watch = function() {
	say("You look at the blank TV screen for a while.");
	say("It's actually better than most channels.");
};
</code></pre>

<p>Which, considering one is based on natural language, while the other was specifically designed to be a very compact notation, is quite an achievement! And note that in the Jaiffa code above, no exits are created back from the adjacent rooms, so I7 wins even before counting its many technical advantages.</p>

<p>I was planning to end the article here, but the next day I continued playing with the system, and I must say that the experience changed completely. It turned into one of swearing, browsing the manual frantically and trying things at random. Look, I understand that I7 is still a programming language in the end, but seriously? You have three different ways to phrase something and none of them works? And you give me a verbose, friendly but totally useless error message? Sorry, but this just reinforces my view that a computer should never, ever try to second-guess a human being. Give me a real programming language. Next time, <a href="tads3-review.html">TADS 3</a>.