Skip to content

A language for interactive stories

Once upon a script.

Write it like a screenplay, run it like a game. Bruja is dialogue and choices as syntax, plus a small, Lua-style language for everything else. For RPGs, adventure games, visual novels, interactive fiction, mods and game logic.

dotnet tool install -g Bruja.Cli · Unity package · VS Code · Source

story.bruja
// This story is running in your browser, right now.
gold = 12

# The Gate
> @Guard: [Halt! Who goes there?|Still here?|You again.]
    * Show your pass
        > @Guard: That's a napkin.
    * {gold >= 5} Offer a bribe
        gold -= 5
        > @Guard: I saw nothing.
        -> city
    + Roll for it
        roll = 2d6
        if roll >= 8:
            > You roll {roll}. He sneezes; you slip past.
            -> city
        > You roll {roll}. He grabs your collar.
-> the_gate

# City
> The city opens up, loud and bright.
> You have {gold} [count: gold | gold coins | gold coin | gold coins] left.

Waking the storyteller…

Press 1–3 to choose

That's a real story, compiled and running in your browser. Pick a choice and watch which line of the script ran.

Two languages' worth, in one.

Writers get Ink's screenplay feel. Programmers get closures, generators and events. It's the same file.

Choices that remember

* choices disappear once picked, + choices stay, and {conditions} show a choice only when it makes sense.

# Tavern
> @Barkeep: What'll it be?
    * Ask about the old map
        > @Barkeep: Gone. Sold it last winter.
    * {visits("tavern") > 1} Ask again, louder
        > @Barkeep: Still gone.
    + Leave
        -> street
-> tavern

# Street
> The door swings shut behind you.

Text that changes

Sequences, cycles, random picks, plurals and lists, right inside a line.

bag = ["a rope", "a lamp", "three apples"]
for day in 1..3:
    > [Morning.|Another morning.|The last morning.] You carry [and: bag].
    bag.pop()
> You have [count: len(bag) | nothing | one thing | {len(bag)} things] left.

Speakers, markup and tags

@Name (mood): says who is talking, <i>markup</i> styles the text, and #tags ride along for the game.

> @Mira (worried): Did you hear <i>that</i>?<pause=0.6> #sfx:thunder
    * Hold the lantern up #icon:lantern
        > @Ash: Just the storm.
    * Say nothing
        > @Mira: ...right.

Same scene, five ways.

A merchant, a purchase you can make once, a dice roll to haggle, a way out. Compare for yourself.

Bruja13 lines
# Market
> @Merchant: Fine blades, cheap!
    * {gold >= 10} Buy a sword
        gold -= 10
        > @Merchant: A fine choice.
    + Haggle
        if 2d6 >= 9:
            > He sighs and says the price is still ten, but he says it nicely.
        else:
            > He laughs at you.
    + Leave
        -> square
-> market
Ink15 lines
=== market ===
Merchant: Fine blades, cheap!
* {gold >= 10} [Buy a sword]
    ~ gold -= 10
    Merchant: A fine choice.
+ [Haggle]
    ~ temp roll = RANDOM(1, 6) + RANDOM(1, 6)
    {roll >= 9:
        He sighs and says the price is still ten, but he says it nicely.
    - else:
        He laughs at you.
    }
+ [Leave]
    -> square
- -> market

Made to live inside a game.

A small .NET runtime with no dependencies, MIT-licensed, tested on Mono and IL2CPP. A Unity package is included.

The game asks for the next line

Like Ink, your game pulls one line at a time, so it owns the UI, timing and voice.

story.Start(program);
while (story.CanContinue) {
    string line = story.Continue();
    var choices = story.CurrentChoices;
}

Tags and game functions

#tags ride along with lines. extern declares functions the game provides.

extern giveItem
> @Keeper: Take this. #vo:keeper_04
giveItem("lantern")

Pause for the game

wait hands control back for an animation, a fight, a cutscene.

> The bridge collapses.
wait "cutscene_bridge"
> You wake on the riverbank.

Save anything

One call saves the whole story: variables, visits, even a paused generator.

byte[] save = story.SaveState();
// …later
story.LoadState(save);
  • Errors before it runs. Every problem with its line and column: typos, missing threads, misspelled speakers.
  • Repeatable randomness. Seed the dice and every playthrough replays exactly, on every platform.
  • Ship the compiler too. The compiler is MPL-2.0, so players can write mods that compile in your game.

Ship it in every language.

Every line gets a stable ID. Translators get a spreadsheet, the game switches language at runtime, and the script never changes. Pick a language:

Waking the storyteller…

fr.csv
g01Halte ! Qui va là ?
g02Ah, {0}. Vous avez {1}.
g02.1aucune pièce
g02.2une pièce
g02.3{0} pièces
g03Payer le péage
g04<b>Merci.</b> Circulez.
g05Passer sans payer
g06{0}
g06.1Hé !
g06.2J'ai dit hé !
g07La porte se referme derrière vous.
  • IDs that survive rewrites. #line:g01 stays put when a line is reworded or moved, so translations and recordings stay attached.
  • A table translators know. CSV with the speaker, notes from the script, and what each {0} stands for.
  • Checked before it ships. bruja lines import catches unknown IDs, broken placeholders and markup, and fails the build.
  • Voice-over ready. The current line's ID is a file name: vo/fr/g01.ogg. The localization guide

How it compares.

The short version. The full table is on the Why page, along with where the others are stronger.

FeatureBrujaInkYarn SpinnerRen'PyLuaLuau
Dialogue and choices are syntax YesYesYesYesNoNo
Once-only, sticky and fallback choices YesYesPartialPartialNoNo
Localization by line ID, with CSV tools YesNoYesPartialNoNo
Loops, arrays and objects YesLists onlyNoPythonTablesTables
Functions and closures YesFunctionsFrom the gamePythonYesYes
Errors before the story runs YesYesYesLintNoTypes

Free course · 36 short lessons · no sign-up

The Quest

Ten short chapters, one small mystery. You'll write The Lighthouse from its first line to a finished game you can share, and meet every major feature on the way. Progress saves as you go.

  1. 1First words
  2. 2Crossroads
  3. 3Threads
  4. 4Remembering
  5. 5Living text
  6. 6Logic
  7. 7Building blocks
  8. 8Scenes that pause
  9. 9Talking to the game
  10. 10The full story

Know Lua already? There's a six-lesson fast lane.

Lesson 1, task 1 Write a line of dialogue. Lines start with >.

Continue in lesson 1 →