Hexicon
Hexicon is a system for writing interactive fiction, of both kinds authors 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, as Twine and ChoiceScript games are;
and of the two together: moments of choosing inside a parser game, or a game played by choosing with a whole world under it, where a choice to take the lamp is a real TAKE, which the world can refuse. It has three parts:
- the language a game is written in, 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; and the player, which plays it in a window of its own, with its pictures, sounds, and styled text, as a web browser does.
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. But it 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
Hexicon's releases have installers for Windows, macOS, and Linux, with the player and the hexicon program both. With Rust installed (rustup.rs), hexicon alone can be installed from crates.io instead:
cargo install hexicon
Hexicon is written in Rust, and builds with Rust 1.98 or later, which rustup keeps current. To build it yourself, from this folder:
cargo build --release
That makes one program, hexicon, in target/release, with Hexad and everything else a game needs inside it. Then:
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. Install it from the Extensions view, searching for Hexicon, or with:
code --install-extension jeffnyman.hexicon
It gives the language its colors, in Hexicon sources (.hxn, .hxh) and in English ones (.hxe), and through a language server that is the hexicon program itself (hexicon lsp) it gives:
- each game's problems as you type, where on their lines they are;
- the outline;
- Go to Definition, into Hexad's own files too;
- 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.
The extension does not bring the hexicon program with it: it finds the one you have installed, or built, and says where to get it if there is none. Its README says what it does in full, and how to work on it.
Playing in a window, or in a browser
The player, hexicon-player, shows a game in the system's web view (WebView2 on Windows, WebKit on macOS and Linux), and web/ is the same page for a browser. Both need the WebAssembly build (see the top of tools/build-web.sh for what that takes):
tools/build-app.sh
target/release/hexicon-player my-game.hxg
A game can also be opened from the player's window, or dropped on it. The player keeps each game's saved games as files, in Hexicon in your documents, with a folder for each game; its "Saved games" button opens it. Saving and restoring show the system's own file dialog, starting in that folder.
On Windows, tools/build-installer.sh builds an installer, build/installer/hexicon-<version>-setup.exe, with Inno Setup 6. It installs for you alone, with no administrator's rights: the player, which then opens .hxg files when they are opened in Explorer, and the compiler, on your PATH, unless you untick it. Settings > Apps uninstalls it. The programs are not signed yet, so Windows may warn before the installer runs, and an antivirus program may hold the player the first time it starts while it checks it.
On a Mac, tools/build-mac-app.sh builds the player as an app, build/mac/Hexicon.app, which opens .hxg files from the Finder, and a disk image to hand to others, build/mac/Hexicon-<version>.dmg (UNIVERSAL=1 builds it for Apple silicon and Intel Macs both). The app is signed for the Mac that built it alone; another Mac will refuse it until it is signed and notarized for a release.
On Linux, tools/build-linux-package.sh builds the player and the compiler as packages to hand to others, in build/linux: a .deb for Debian, Ubuntu, and the distributions made from them, which sudo apt install ./hexicon_<version>_<arch>.deb installs with what the player needs (WebKitGTK, and GStreamer's plugins for the games' sounds); and a .tar.gz of the same files for any other, with a README of what to install. Either puts the player in the desktop's menus, opening .hxg files from a file manager, and the compiler on your PATH. Building them needs dpkg-dev as well as what tools/build-app.sh needs.
On GitHub, every push to main and every pull request is checked (.github/workflows/checks.yml), with the newest Rust and with the oldest Hexicon builds with; and pushing a tag that starts with v builds Windows's installer, the Mac app, Linux's packages, and the VS Code extension, and makes a release with them (.github/workflows/release.yml). The .deb names its maintainer from the repository's Actions variables DEBFULLNAME and DEBEMAIL. The crates are published to crates.io by hand, with tools/publish-crates.sh (see its top), at the release's version.
tools/build-web.sh builds the browser's page alone, into web/; node tools/web-serve.js serves it at http://127.0.0.1:8765/web/index.html.
Documentation
The Hexicon Guide takes you from nothing to a small finished game, and covers Hexad and the language. Its page Choices is about choice games, from one moment of choosing in a parser game to a game played by choosing alone, and hexicon new --choices starts one. Its page Writing in English is about writing a game in sentences ("The Rocky Shore is a room."), in .hxe sources, with blocks of the language for the rest. The plans behind Hexicon are in docs.
Testing
cargo test
python tools/program-check.py
python tools/doc-check.py
cargo test leaves out the player, which needs the page built first; with it built, cargo test --workspace includes it.
tests/README.md says what each 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.