Playing with Inform Tooling, Part 1: Setting Up

Posted:
Tags:

Inform is a programming language whose syntax closely resembles natural English; its original purpose was to make interactive fiction (IF) authorship accessible to authors of the traditional sort, though in theory it is now possible to use Inform to write other, more general-purpose programs if you really want to. I have previously written a brief introduction to both IF and the Inform language.

Inform is normally written using the cross-platform integrated development environment (IDE). Aside from the code itself, this provides easy access to documentation, examples, a playtesting session, and an index of every room, item, etc. defined in your source text.

This post is not about that.

Or rather, this series of posts; I initially set out to write one, but as it grew longer and longer—and was still only perhaps half done—I found the task of finishing it an increasingly daunting proposition. Therefore, I have decided to break it up into pieces, in order that I might buoy my spirits periodically with the dopamine rush that comes from having actually published something.

While the Inform IDE looks basically the same on all supported platforms, each one actually has its own separate codebase. Behind the scenes, however, each depends upon the same handful of command-line (CLI) tools; these form the core of the language, and can be used a bit more flexibly by themselves. This first post covers how to obtain Inform’s CLI tooling, as well as a few words about why on Earth you might want to do such a thing. The second shall explain how to use those tools with a traditional Inform project, as produced via the IDE. The third (and, possibly, any that come after it) will stray further from the norm, and start bending things to suit—theoretically—whatever workflow or project structure you might prefer.

Why on Earth might you want to do such a thing?

The Inform IDE is really quite impressive, and these posts are not intended in any way to denigrate it or the people involved in maintaining the versions for each platform. However, it is what it is; it offers no extensibility1 and very little in the way of configurability, two things in which career programmers tend to become rather invested. Speaking plainly: I can’t use Vim keybindings.

(Half-)jokes aside, Inform has an unconventional approach to program organization. Just as the syntax is modeled after natural English, the program structure resembles a manuscript: a single document, subdivided by headings into “volumes”, “books”, “parts”, “chapters”, and “sections”. These have hierarchical meaning, but no semantic meaning; it’s up to each individual author to decide how best to map their code into these divisions. Coming from a C# background, I’m accustomed to more concrete organizational keywords like namespace, class, and interface, and to having separate, nested folders for the namespaces and individual files within those folders for each class or interface. I started down this path looking for a way to organize Inform code into multiple files, and continued partly because I met with some success and partly because I really enjoy discovering how things work.

Prerequisites

The remainder of this series assumes a unix-like system, including access to such programs as Bash, Git, Make, and a C compiler such as that provided by the GNU Compiler Collection (GCC). If you’re on a macOS or Linux machine, you should be set, although some of the tools you’ll need might not be pre-installed. If you’re on Windows 10 or 11, check out the Windows Subsystem for Linux (WSL). If you’re on an older Windows version, your operating system is no longer receiving security updates and you should really think about upgrading; but, you might have luck with something like Cygwin.

On Ubuntu specifically, you’ll want to install the git and build-essential packages, which you can do in one command:

sudo apt install git build-essential

Everything else should already be available. If you’re not using Ubuntu, I trust that you are more familiar with your system’s package-management software than I am.

Obtaining the Inform tool set

As mentioned earlier, the Inform IDE depends on these same tools, so one way to get them is to install the IDE for your platform and then… find them. However, depending on how exactly you install it (e.g., Flatpak) these might end up in any number of places, or you might be using an unsupported platform like one of the BSDs, so on balance I think it’s probably simplest just to compile them from source (which, honestly, is pretty straightforward). The following instructions are largely the same as those found in each tool’s GitHub repository, but all in one place and with a couple of extra steps thrown in.

First, create a directory in which to clone the repositories:

mkdir -p ~/code/inform-tools
cd ~/code/inform-tools

Next, build the Inweb and Intest tools, which are the compiler and testing system, respectively, for the rest of them. The git switch step ensures we use the code corresponding to a particular release, rather than whatever might be currently under development; most likely, you want to use (after -d) the tag corresponding to the most recent version. The -help step is just to confirm that the compiled program is working.

git clone https://github.com/ganelson/inweb.git
git -C inweb switch -d v7.2.0
bash inweb/scripts/first.sh linux
inweb/Tangled/inweb -help

git clone https://github.com/ganelson/intest.git
git -C intest switch -d v2.1.0
bash intest/scripts/first.sh
intest/Tangled/intest -help

Now we are ready to build the core Inform tools. For this one, it’s important to actually cd inform instead of just using Git’s -C option, because the build script expects to be run from within the inform directory.

git clone https://github.com/ganelson/inform.git
cd inform
git switch -d v10.1.2
bash scripts/first.sh

This one takes a bit longer and produces a lot more output than the first two. When it’s finished, you can run a single test from the Inform test suite to make sure it’s working. (You could also run the entire test suite, but that takes significantly longer.)

../intest/Tangled/intest inform7 -show Acidity

We now have access to three key tools:

There are also Inbuild and Inter, which are sub-components of inform7; and a couple of others, none of which are needed for our purposes. If you’re interested, you can read about them in the official documentation.

For convenience, create shortcuts to the three tools mentioned above somewhere in your $PATH. On Ubuntu, ~/.local/bin is an idiomatic choice.

cd ~
mkdir -p ~/.local/bin
ln -s ~/code/inform-tools/inform/inform7/Tangled/inform7 ~/.local/bin/inform7
ln -s ~/code/inform-tools/inform/inform6/Tangled/inform6 ~/.local/bin/inform6
ln -s ~/code/inform-tools/inform/inblorb/Tangled/inblorb ~/.local/bin/inblorb

If ~/.local/bin didn't already exist, you may need to relaunch your shell; the default .bashrc on Ubuntu only adds this directory to the $PATH if it exists when the .bashrc is executed.

The Treaty of Babel

Finally, we’re going to want a couple of tools from the Treaty of Babel software suite. These aren’t specific to Inform, but rather are designed to process the standard metadata format shared by all IF authoring systems that comply with the standard established by the treaty.

First, the babel tool itself, which can be used to inspect story files and metadata files, and verify that they conform to the standard:3

git clone https://github.com/iftechfoundation/babel-tool.git
cd babel-tool
git switch -d v0.6
make babel
./babel -help
ln -s ~/code/inform-tools/babel-tool/babel ~/.local/bin/babel

And secondly, the ifiction-xtract tool. This is provided within the Babel distribution as a demonstration of how to use the Babel API in other programs, but it is nonetheless useful for extracting the values of specific tags from a metadata file. The makefile doesn’t have a target for this, so we have to compile it more manually; per the instructions in the README:

cd extras
gcc -c -I.. ifiction-xtract.c
gcc -o ifiction-xtract ifiction-xtract.o ../babel.a ../ifiction.a
./ifiction-xtract -help
ln -s ~/code/inform-tools/babel-tool/extras/ifiction-xtract ~/.local/bin/ifiction-xtract

Footnotes

  1. To be clear, I’m talking about extensions that change the behavior of the IDE itself, not the program libraries that are called extensions in the Inform nomenclature. ↩︎

  2. The blorb file format is a standard way of packaging an IF story file (produced by one of several authoring systems) along with its resources (cover art, metadata, and possibly pictures or sounds) that can be understood by various software for playing and/or cataloging IF games. It is named after the “blorb” spell from Infocom’s Enchanter (1983), which “safely protect[s] a small object as though in a strong box.” ↩︎

  3. If you prefer, you can obtain the source directly from the Treaty of Babel website instead of GitHub:4

    curl --output babel-0.6.zip http://babel.ifarchive.org/downloads/babel-0.6.zip
    unzip babel-0.6.zip -d babel-tool
    rm babel-0.6.zip
    cd babel-tool
    

    And then pick up above with the make babel step. ↩︎

  4. I included this footnote because I had already written these instructions by the time I found the GitHub repo, before which time I thought the Treaty website might be the only way it was distributed. ↩︎