IFLoom and Twine
Twine is where most interactive fiction starts, and SugarCube is its most-used story format. IFLoom is a TypeScript engine for when a story grows into a game with systems. Here is how they differ, where each is the better choice, and how to move a story over.
Twine with SugarCube, and IFLoom
| Topic | Twine with SugarCube | IFLoom |
|---|---|---|
| How you write | A visual map of passages, in the browser or the desktop app for Windows, macOS and Linux, each passage in the story format’s markup. | TypeScript files in your own editor: scenes, choices and their words as data, written beside the code that runs them. |
| Getting started | Nothing to install in the browser, and no code for a first story. | Node and a code editor. npm create ifloom makes a game, and the tutorial takes it from there. |
| The engine | A story format you choose: Harlowe (the default), SugarCube, Chapbook or Snowman, each with its own markup and macros. | One engine, with plugins for whole systems: a calendar, places, a cast with schedules, jobs, shops, quests, a wardrobe and more. |
| State | Story variables such as $coins, kept in a history of moments, one for each passage the player moves to. | Stats with ranges, a key-value store, and entities: the things, people and places the player holds and meets. |
| Logic | Macros in the passage: <<if>>, <<set>>, links that set variables, and your own with <<widget>> or Macro.add in the story’s JavaScript. | Conditions and effects as data, choices that cost and refuse with a reason, and typed calls of your own in the game’s rules. |
| Catching mistakes | Test mode turns on SugarCube’s debug views and warnings while you play. | ifloom check reads the whole game before anyone plays: a scene that isn’t there, a misspelt stat, a missing picture, each with where it is. TypeScript flags the rest as you type. |
| Testing | Playing it yourself, in Test mode. | ifloom playtest plays days of the game and writes a transcript, ifloom snapshot records every scene to compare after a change, and the game’s tests run in Vitest. |
| Saves after an update | Saves sit in the player’s browser storage, and can be saved to a file. To load a save from an older version, you write a Save.onLoad handler that upgrades it. | A save records the game’s version, and each change to what a save holds is a migration step the engine runs as an old save loads. |
| Look and feel | The story format’s page, styled with the story’s CSS and JavaScript. | The React UI, with themes and presets, or a UI of your own in Vue, Svelte or plain JavaScript, from the same view of the game. |
| What you publish | One HTML file, straight from Twine. | One HTML file and its art, from ifloom build. It opens from disk, with no server. |
| Files and version control | The story lives in Twine’s library, in browser storage or a folder. Tweego compiles plain-text Twee files, for a text editor and git. | Plain files from the start, so git, diffs and code review work as they do for any code. |
| Community | Large and long-standing: the Twine Discord, the intfiction.org forum and the Twine Cookbook. SugarCube has the most resources of the formats. | New: the docs, the example games and GitHub. |
| Licence and cost | Free and open source. Twine is GPL-3.0, Tweego a BSD licence. | Free and open source, MIT. |
The same passage in both
A bakery that sells a loaf for three coins. In SugarCube the link to buy shows only when you can pay. In IFLoom the price is on the choice: its button says 3 coins, and with two it's greyed out with Not enough coins., with no second <<if>>. ifloom check reports the home and street scenes until they exist.
:: Bakery
<<if $coins gte 3>>
The baker slides a warm loaf across the counter.
[[Buy the loaf|Home][$coins -= 3; $bread to true]]
<<else>>
"Three coins," the baker says. You count two.
<</if>>
[[Leave|Street]]import type { Content } from '@ifloom/engine'
export const bakery: Content = {
stats: [
{ id: 'coins', label: 'Coins', start: 2, spendable: true,
format: '{n} coins', lacking: 'Not enough coins.' },
],
scenes: [
{
id: 'bakery',
title: 'The bakery',
body: [
{ text: 'The baker slides a warm loaf across the counter.',
when: { stat: 'coins', gte: 3 } },
{ text: '"Three coins," the baker says. You count two.',
when: { stat: 'coins', lt: 3 } },
],
choices: [
{ id: 'buy', label: 'Buy the loaf', cost: { stats: { coins: 3 } },
effects: [{ kv: 'bread', to: true }, { scene: 'home' }] },
{ id: 'leave', label: 'Leave', effects: [{ scene: 'street' }] },
],
},
],
}Both are good tools, for different stories
Choose Twine when
- You want to write without code, and see the story as a map.
- You’d rather write in the browser, with nothing to install.
- The story is short, or an experiment, and its logic fits in a few variables.
- You want the tutorials, templates and answers a large community has built up.
Choose IFLoom when
- The story is becoming a game with systems: a clock and a week, places to go, people with schedules, money, jobs and shops.
- It will grow for a long time, or with other people: types, a checker, tests and saves that survive updates keep it from breaking quietly.
- You want it in git, with diffs and review, like the rest of your code.
- You want a UI of your own, in React, Vue, Svelte or plain JavaScript.
What carries over, and what you rewrite
Most of a SugarCube story maps across directly. Each passage becomes a scene and each link a choice. Variables become stats and keys, StoryInit becomes their starting values, and a speech macro becomes a spoken line under a character, with their portrait. A day-and-time system is the calendar plugin, and locations are the places plugin.
What needs rewriting is code that builds the page: widgets and macros that print HTML, and inline JavaScript. Those become blocks, rules or UI components. Players' saves don't carry over, so a moved game starts fresh.
Coming from Twine
Can I import my Twine story?
Not automatically. A passage becomes a scene and its links become choices, one for one, so a short script over the passages can do most of the converting. Macros that only change variables become effects or rules, and macros that build HTML need rewriting. The Move from Twine guide converts a passage, and the phrasebook maps each macro.
Do I need to know TypeScript?
A little. Content is TypeScript objects, and the tutorial starts from an empty project. Your editor fills in field names and points out mistakes as you type, which makes it gentler than it sounds.
Does the game still open from disk, and go on itch.io?
Yes. ifloom build makes one HTML file with its art beside it, which opens from disk with no server, so it zips up for itch.io as a Twine game does.
Can I still write prose?
Yes. A scene’s words are written as text, spoken lines go under who says them, and {{tokens}} print names and numbers. Text you reuse goes in a table of lines by key.
Is IFLoom free?
Yes. It’s open source under the MIT licence, on npm and GitHub.