Dialogue scripts (.vn)

Write a scene as plain text. events/town/sign/index.vn becomes the event 'town/sign', just like an index.ts would. So does the single file events/town/sign.vn.

An example

# The town sign. Lines starting with # are comments.
title The town sign
> An old wooden sign. Someone carved a message into it.
> {i}"Welcome to town. Be kind to the slimes."{/i}

if flag('read_sign'):
  > You have read it before. It hasn't changed.
else:
  set read_sign = true
  > Behind the sign, half buried, something glints.
  choice:
    * Dig it up
      give apple
      money +5
      > An apple and a few coins. Lucky!
    * Leave it
      > You leave it where it is.

A file in src/content/routes/ is a route script instead (the story's order in visual novel mode): see Routes & flowchart.

Every file needs one title line (not indented, usually at the top): the event's name on saves made during it, like a map's title.

Blocks are made by indenting (spaces): the options of a choice:, and the body of if / elif / else. Blank lines don't matter.

One file per scene

A scene does not need a folder of its own. Any <name>.vn file in src/content/events/ or one of its group folders is an event, named by its path:

src/content/events/
  common/day1_morning.vn        # the event 'common/day1_morning'
  common/day1_lunch.vn          # 'common/day1_lunch'
  common/day1_evening/index.vn  # 'common/day1_evening' (a folder, e.g. to keep its pictures with it)
  common/_notes.vn              # ignored (starts with _)

How it works

Lines

WriteDoes
anna: Hello!Anna says it
anna:happy: Hello!…and switches to her happy pose (shows her if needed)
anna(italic, speed 0.5): Hello!…with line options in round brackets, before the colon
jack & anna:happy: Bye!Said together: name tag "Jack & Anna", the plain chat box, nobody of them dimmed. Voices: jack & anna(3, 7): Bye! (one number per speaker, in name order). See Several voices
"Student A": Hello!A speaker who is no character: the name in quotes is shown as written (and can be translated). No portrait, no folder needed
>(italic) TextNarration with line options (no space between > and the bracket)
> TextNarration
# commentIgnored
$ any TypeScriptOne line of code, e.g. $ await game.maps.npc('jack').play('wave')

Line options

Separate them with commas: anna:happy(12, as ???): Guess who.

OptionDoes
as ??? · as "Anna, the baker"Shows another name for this line (quotes when it has a comma)
italic · shakeSlanted / shaking text
size small · size large · color #ffcc00Text size and colour
speed 0.5Typing speed (2 = twice as fast)
auto 800Continues by itself 800 ms after the text is shown
nopauseNo short pause after . ! ? while typing
jack 3 · jack town/x/jack_0001Another voice too, from someone who is not the shown speaker: anna(7, jack 3): Hm. (both clips start together)
12 · 0012 · voice town/arrival/anna_0003The line's voice number (its file: audio/voice/<language>/<event id>/anna_0012.*) / a clip of another event. No number = no voice. See Voices
face happyThe pose of the side image for this line
thought (any other word)A named line style from lineStyles in src/content/scenes.ts: hero(thought): I wonder.... One per line; the other options win over it
// src/content/scenes.ts
lineStyles: {
  thought: { italic: true },
  whisper: { size: 'small', speed: 0.7 },
  shout: { size: 'large', shake: true },
},

Put a value into a line with [ ], like Ren'Py: anna: You have [money()] coins. Inside the brackets is TypeScript (a variable from a $ line, a helper, game.…). Translators see {money}. Write [[ for a plain [.

Text supports the same markup: {b}, {i}, {color=…}, {size=…}, {shake}, {wave}, {w=0.5}.

Commands

CommandSame as
show anna at left pose happy flipshow('anna', { at: 'left', pose: 'happy', flip: true }) (all parts optional)
show anna distance closeHow near she stands: a name from stage.distances in src/content/scenes.ts
show anna tint night · show anna tint noneA tint or filter on her only (tints)
show anna frame 0.65 1 · frame anna 0 0.35 ms 2500Which part of her picture fills the stage (top to bottom, 0..1): show it at once, or animate to it (framing)
@start · @start wave trustDev only: the dev server opens the game at this line (more). Builds refuse it
hide anna / hideRemove one / everyone
bg street · bg town/bus_stop eveningbg(…): a background from src/content/backgrounds; one with variants (an .aseprite + index.ts) needs the variant
bg #203040 · bg black · bg /img/sky.png · bg nonebackground(…): a colour (#…, rgb(…), a basic colour word), a file or URL, or none = the map
bg #203040 with wipeLeft 800 · cg pond_memory with swirl…through a mask transition (ms optional)
movie /video/opening.mp4await movie(…): plays a video, then goes on
image letter /img/letter.png x 50 y 40 width 30 layer top ms 500 · image letter none · image nonePictures on stage: show or move one, take one away, take all away. Also height, opacity, scale, rotate
weather snow 0.5 · weather noneWeather in the scene (intensity optional)
move anna hopA named move
nvl on · nvl clear · nvl offFull-page text: start, new page, back to the box
ending true_endMarks an ending as reached
title The town signThe event's title (required, once, not indented): shown on saves
chapter townA chapter begins here (await chapter("town"): the stage lines after it go under a covering card)
$ const name = await input('Your name?')Asking for text (then anna: Hi [name]!)
cg pond_memory · cg pond_memory crying.full_moon · cg noneGallery picture or one of its variants (and unlock it)
inset sneaking red_girl · inset closeup ms 800 · inset noneA framed picture in the middle (src/content/insets, optional variant and fade ms)
filter flashback · filter noneFilter preset or tint over the whole stage
filter evening on characters · filter night on anna · filter none on backgroundOnly one part: all, background, characters or a character (tints)
fade #000 400 · fade none 400Fade to a colour / back
wait 0.5Pause (seconds)
music music/town · music none · ambient ambient/rain · sfx sfx/clickSound
event anna/flashbackRun another event here
set met_anna = true · set talks += 1 · set talks -= 1Flags (the value is TypeScript)
give apple 2 · take appleItems (with a toast when given)
money +10 · money -5Money
love anna +3Relationship points (with a toast)
rename god "Evil God" · reveal godShow another name / the real name from now on (Names that change)
xp 20 · join annaParty XP · add to the party
achievement builder · codex annaUnlock
quest start jacks_letter · quest step jacks_letter read · quest done jacks_letterQuests
window inventory · shop annaOpen a window / shop
battle slime, bat
battle wolf_pack
A battle (waits for it): enemies, or a troop from content/troops
end (or return)Stop the event here

At the same time

Commands like fade wait until they finish. Put meanwhile in front to start one and go on at once:

meanwhile fade #ffffff51 2000
meanwhile $ await animate('god', { opacity: 1 }, { duration: 1000 })
hero: Ehh... What?

together: starts every line below it at once and goes on when all of them are done:

together:
  hero: Ehh... What?
  fade #ffffff51 2000
  $ startShake(6)
fade #ffffff 2000

Choices and conditions

Condition helpers: flag('name'), has('item'), love('anna'), money(), inParty('hero'), seen('event/id') (see Run once) and variant('adult') (this build's content variant).

choice:
  * Yes, please
    anna: Great!
  * Only friends see this if love('anna') >= 10 and not flag('met_anna')
    > A secret option.
  * No

if flag('met_anna'):
  anna: Again?
elif has('apple', 2) or money() > 50:
  anna: Rich!
else:
  anna: Hi.
Helper
flag('met_anna')A flag's value
has('apple'), has('apple', 3)Carrying it
love('anna')Relationship points
money()Money
inParty('anna')In the party
seen('anna/hello')That event has started in this playthrough
variant('adult')This build is that content variant

Anything else: write TypeScript, e.g. if game.clock.hour() >= 20: or $ const roll = random(). game, ctx and every scene command (say, show, animate, camera, shake, flash, random…) are available by name.

Editor extension

Kroniki VN Scripts, for VSCodium / VS Code: colouring, suggestions and red underlines while you type.

  1. Build it: pnpm vn:extension → build/vn-extension/kroniki-vn-scripts-<version>.vsix.
  2. In the editor's Extensions view: the … menu → Install from VSIX… → pick that file.

The rules live in vite/vn/: compile.ts (to TypeScript), check.ts (ids), complete.ts (suggestions), ids.ts (reads the project). The extension and the dev server share them.

Adding a command

  1. Add a case in command() in vite/vn/compile.ts (it returns one line of TypeScript).
  2. If its argument is an id, add it to COMMAND_ARGS in check.ts; add a suggestion to COMMANDS in complete.ts; add the word to the grammar in tools/vscode-vn/syntaxes/vn.tmLanguage.json.
  3. Add a test in vite/vn/*.test.ts, update this page, rebuild the extension.