Hexicon
Hexicon is a system for writing interactive fiction, focusing on two kinds that authors tend to write.
- parser games, played by typing commands such as
open the boxorgo north - choice games, played by choosing from a list, by a click or a number (think Twine and ChoiceScript)
You can create games that mix the two together: moments of choosing inside a parser game, or a game played by choosing with a whole world model under it, where a choice to take the lamp is a real TAKE, which the world can refuse.
Hexicon is made up of three parts:
- the language a game is written in (
.hxnfiles) - Hexad, the library every game is built on: rooms, things, doors, characters, the parser and the choices, and the messages a game prints
- the
hexiconprogram, which builds a game into a single.hxgfile and plays it in a terminal - the player, which plays the compiled game in a window, with its pictures, sounds, and styled text, just as a web browser displays it
Hexicon owes much of its design to TADS 3 and the libraries written for it: the shape of its language, its model of a game's world, and the way that world answers what a player does. That being said, Hexicon is its own system, not a version of TADS. It is not bound to be compatible with TADS 3: its games, files, and libraries are Hexicon's own, and it changes as and when I come up with more and (hopefully!) interesting ideas.
Getting started
The easiest way to get Hexicon is an installer from the releases. There are installers for Windows, macOS, and Linux, and each one installs both the player and the hexicon program.
If you have Rust installed (rustup.rs), you can instead install the hexicon program from crates.io. This gives you the program only, not the player:
cargo install hexicon
You can also build Hexicon yourself. It is written in Rust and needs Rust 1.98 or later (rustup keeps Rust up to date). From this folder:
cargo build --release
That builds the hexicon program into target/release. Hexad, and everything else a game needs, is built into the program. Then, to jump start creating a game:
hexicon new my-game
cd my-game
hexicon build
hexicon run my-game.hxg
Writing in VS Code
The VS Code extension, Hexicon (jeffnyman.hexicon), is for writing games in VS Code. It is published in the Marketplace: search for Hexicon in VS Code's Extensions view, or run:
code --install-extension jeffnyman.hexicon
It colors the language, both in Hexicon sources (.hxn, .hxh) and in English ones (.hxe). Through a language server, which is the hexicon program itself (hexicon lsp), it also gives you:
- each game's problems as you type, marked where they are on the line
- the outline
- Go to Definition, including into Hexad's own files
- Find All References, and Rename
- hover and completion
It also:
- builds a game, and plays it in a tab, which is Hexicon's player
- runs a game's scenarios in the Testing view
- shows a game's reference, and Hexad's
- draws a game's map
The extension does not include the hexicon program. It finds the one you installed or built, and if there is none, it tells you where to get it. The extension's README describes everything it does, and how to work on it.
Playing in a window, or in a browser
The player, hexicon-player, shows a game using the system's web view (WebView2 on Windows, WebKit on macOS and Linux). The page in web/ is the same player, for a web browser.
If you used an installer from the releases, you already have the player. It is in your system's menus, and it opens a .hxg file when you open one from Explorer, the Finder, or a file manager. (cargo install hexicon installs only the hexicon program, not the player.)
The programs are not signed yet, so the first time you use them:
- Windows may warn you before the installer runs, and an antivirus program may hold the player the first time it starts, while it checks it.
- macOS will not open the app at first, saying that Apple could not check it. To open it anyway, try opening it once, then go to System Settings > Privacy & Security, where Hexicon is listed with Open Anyway. Choose that and confirm. After that, it opens like any other app. (On macOS 14 and earlier, Control-click the app and choose Open instead.)
To build the player yourself, run this from this folder. It first builds the web page and its WebAssembly build, which needs the tools listed at the top of tools/build-web.sh:
tools/build-app.sh
target/release/hexicon-player my-game.hxg
You can also open a game from the player's window, or drop it onto the window.
The player keeps each game's saved games as files, in a Hexicon folder in your documents, with a folder for each game. Its "Saved games" button opens that folder. Saving and restoring use the system's own file dialog, starting in that folder.
| System | Saved games |
|---|---|
| Windows | Documents\Hexicon, in your user folder (C:\Users\<you>\Documents\Hexicon), or wherever Windows keeps your Documents, such as OneDrive |
| macOS | ~/Documents/Hexicon |
| Linux | Hexicon in your desktop's documents folder, usually ~/Documents/Hexicon |
If you have no documents folder, the player uses a Hexicon folder in your home folder instead. To keep saved games somewhere else, such as beside the player on a USB stick, set HEXICON_GAMES_FOLDER to that folder before starting the player.
In a browser, saved games are not files. The page keeps them in the browser's own storage for that site, so clearing the site's data deletes them.
To build just the browser's page, into web/, run tools/build-web.sh. Then node tools/web-serve.js serves it at http://127.0.0.1:8765/web/index.html.
Building the installers, and releases
Windows: tools/build-installer.sh builds an installer, build/installer/hexicon-<version>-setup.exe, using Inno Setup 6. The installer installs for the current user only, and needs no administrator rights. It installs the player, which then opens .hxg files from Explorer, and the hexicon program, which it adds to your PATH unless you untick that option. To uninstall, use Settings > Apps.
macOS: tools/build-mac-app.sh builds the player as an app, build/mac/Hexicon.app, which opens .hxg files from the Finder. It also builds a disk image to give to others, build/mac/Hexicon-<version>.dmg. Set UNIVERSAL=1 to build for both Apple silicon and Intel Macs. The app is signed only for the Mac that built it (an "ad hoc" signature). It is not signed with a Developer ID or notarized by Apple, so on any other Mac it has to be opened as described above.
Linux: tools/build-linux-package.sh builds the player and the hexicon program as packages, in build/linux:
- a
.deb, for Debian, Ubuntu, and distributions based on them.sudo apt install ./hexicon_<version>_<arch>.debinstalls it, along with what the player needs (WebKitGTK, and GStreamer's plugins for the games' sounds). - a
.tar.gzof the same files, for any other distribution, with a README listing what to install.
Either one puts the player in the desktop's menus, opening .hxg files from a file manager, and puts the hexicon program on your PATH. Building them needs dpkg-dev, as well as everything tools/build-app.sh needs.
On GitHub, every push to main and every pull request is checked (.github/workflows/checks.yml). The checks build and test Hexicon with the newest Rust, and build it with the oldest Rust it supports (1.98).
Pushing a tag that starts with v, such as v0.1.0, makes a release (.github/workflows/release.yml). It builds the Windows installer, the Mac app, the Linux packages, and the VS Code extension, and attaches them all to the release. The .deb takes its maintainer's name and email from the repository's Actions variables DEBFULLNAME and DEBEMAIL.
The crates are published to crates.io by hand, at the release's version, with tools/publish-crates.sh (see the top of the script for how).
Documentation
The Hexicon Guide takes you from nothing to a small finished game, and covers Hexad and the language. The tutorial writes one longer game, Calder Ridge, a chapter at a time, from an empty folder to a finished game.
Two of the guide's pages cover the other ways of writing:
- Choices is about choice games, from a single moment of choosing in a parser game to a game played only by choosing.
hexicon new --choicesstarts a new choice game. - Writing in English is about writing a game in sentences ("The Rocky Shore is a room."), in
.hxesources, with blocks of the language for everything else.
To read the guide and the tutorial as a website, build them as HTML pages, with Node 22 or later: run npm ci and then npm run build in tools/docs-site. The pages are written to build/site; open build/site/index.html, or put the folder on any web server.
Testing
cargo test
python tools/program-check.py
python tools/doc-check.py
cargo test leaves out the player, because the player needs the web page built first. Once the page is built, cargo test --workspace includes it.
tests/README.md explains what each of these checks.
License
Hexicon is free software: you can redistribute it and modify it under the terms of the GNU General Public License, version 3 or (at your option) any later version. See LICENSE.
The libraries in lib (the system library and Hexad) carry an additional permission, LIBRARY-EXCEPTION: a game built on them may be distributed under terms of its author's choice.