Skip to content

Cheat sheet

Bruja on one page.

Print it, pin it, forget it. Details are in the language reference.

Dialogue

A line the player reads
> The rain hasn't stopped.
Speaker and portrait
> @Mira (sad): I'm fine.
Value in text
> You have {gold} gold.
Tags for the game
> Halt! #vo:guard_01 #shake
Comment
// only for you

Choices

Question and choices
> Open the door?
    * Yes
        > It creaks.
    * No
Sticky (always offered)
    + Wait
Only when true
    * {has_key} Unlock it
Fallback (no text)
    *
        > Nothing left to say.

Threads

Thread, sub-thread
# Chapter One
## Cellar
Jump
-> chapter_one.cellar
Visit and come back
<- weather
Times entered
visits("cellar")
Pause for the game
wait "door_opens"
Another file
import "chapters/two.bruja"

Text that changes

Sequence (sticks on last)
[Hi.|Hello again.|You again?]
Cycle / random / once
[cycle: a|b]  [any: a|b]  [one: a|b]
Shuffled
[rseq: a|b|c]  [rcycle: a|b|c]
By condition
[if: hp > 5 | strong | weak]
By number
[count: n | no apples | an apple | {n} apples]
Lists
[and: items]  [or: exits]
Markup
<b>bold</b> <i>italic</i> <color=red>red</color> <pause=0.5>

Localization

A line ID
> @Guard: Halt! #line:g01
Add IDs to every line
// bruja lines add -f story.bruja
In a string table (CSV)
// g02: "Ah, {0}. Vous avez {1}."
// g02.1: aucune pièce

Values and variables

Values
null  true  42  1.5  "text"  d20  2d6
Collections
[1, 2, 3]   {name: "Ann", hp: 10}
Variables
gold = 10
local x = 1
const MAX = 3
Change
gold += 5   gold--   hp *= 2
Enum
enum Mood: happy, sad
mood = Mood.sad
Truthiness
// only false and null are false

Control flow

if
if hp <= 0:
    > You fall.
else if hp < 10:
    > You stagger.
else:
    > You stand.
Loops
for i in 1..3:
for item in items:
for k, v in obj:
while i < 3:
switch
switch mood:
    case "happy":
        > Smile.
    default:
        > Shrug.

Functions

Function
func greet(name):
    return "Hi, " + name
Lambdas
square = x => x * x
add = (a, b) => a + b
Generator
func days():
    yield "Mon"
    yield "Tue"
Events
event died
died += name => print(name)
died("goblin")
Game functions
extern give_item, play_sound
Typed answer
name = input("Your name?", "Ash")

Built-ins

General
print  len  keys  has  typeOf
toInt  toFloat  toString  error  assert
Arrays
push  pop  insert  remove  removeAt
contains  indexOf  join  reverse  slice
Strings
toUpper  toLower  substring  split
contains  replace  trim  startsWith
Math
math.floor  ceil  round  abs  min  max
math.random(1, 6)  math.randomInt(a, b)