Scripting Language

Project DVN

Below is the full documentation for the default scripting langauge of DVN.

Contents


Hello World!

[main]
Hello World!

Scene Graph

In DVN, scripts are parsed and compiled into a scene graph made of interconnected scene nodes.
This means DVN is not a simple linear script engine - the graph structure allows flexible navigation across files, scenes, and commands.

Each [SceneName] entry becomes a top-level scene entry node.

Text lines also become nodes, but not top-level nodes.
Text nodes inside the same scene automatically link to the next text node unless a jump is specified.

Because DVN compiles scripts into a graph instead of executing them linearly, you can freely jump between scenes, even across different script files.

Scene names exist in a global namespace.
If two scenes use the same name, DVN will overwrite the earlier scene with the later one.
This behavior is allowed but not recommended, except for debugging.

File order does not define execution order.
You can organize your script files however you want - DVN will still build the correct scene graph.

Syntax

The basic syntax of a DVN script is like below:

[scene-name]
commands

Where commands have the following syntax generally:

key=value

Commands may only exist on a single line and cannot span across multiple lines.

The DVN scripting language uses key=value syntax internally. Because of this, raw = characters inside a value would break parsing.

If you absolutely need the = character in a text line then please use the specialized token __EQ__ in your text.

For example:

t=1 + 2 __EQ__ 3

will output:

1 + 2 = 3

You may include white spaces in your text values, BUT not before or inbetween separators.

Also most commands have shorthand aliases like characters= being the same as c=

It is possible to ommit the = for some commands like narration text will be implicit if you don't write a command.

Ex.

Hello World!

Is equal to:

t=Hello World!

INI-like Structure

DVN scripts uses an INI-like structure because it is easy to maintain and human-readable.

This makes DVN feel closer to narrative scripts, than coding.

Each scene is split into sections similar to INI.

[scene-1]
...

[scene-2]
...

[scene-3]
...

Within each section you specify your scene commands.

[scene-1]
bg=Background
My first scene.
t:scene-2=Go to next scene.

[scene-2]
My second scene.
t:scene-3=Go to next scene.

[scene-3]
bg=Another_Background
My third scene.
t:end=Go to main menu.

Each command is case-sensitive meaning Text will not work, but text will.

You can split your scenes across multiple files, even in multiple directories.

As long as they exist as either a file or sub directory within data/game/scripts.

Example:

main.vns

[main]
t:another-scene=Go to another scene.

another.vns

[another-scene]
Another scene...

You may prefix your scenes with the * symbol, which means "insert current module name here. This can also be used when jumping to a scene (See flow control for more information).

Example: (main.vns)

# Becomes [main]
[*]
This scene becomes [main]

[*-start]
This scene bcomes [main-start]

Commands

Invalid Commands

Invalid commands are any key= entries the parser cannot interpret.

A command is considered invalid when:

  • it has a key but no value (e.g., Example=), and
  • the key does not exist in the internal command/function list (where commands such as hideDialogue live).

Invalid command lines do not stop execution - DVN will log an error so you know something may need fixing, then continue parsing the script.

Name=Text (Implicit Dialogue Mode)

DVN supports a natural shorthand for writing dialogue using the format Name=Text.

When the parser encounters a key=value format and the key is not a recognized command, DVN automatically treats it as a line of spoken dialogue.

Example:

# Natural format
Ren=This is Ren speaking.
Yume=This is Yume speaking.

# Legacy model
n=Ren
t=This is Ren speaking in legacy mode.

# Nobody speaking
This message has nobody speaking...

# Legacy model
t=This message has nobody speaking...

DVN will attempt to use the last speaker, if found when omitting the name too.

Example:

Ren=This is Ren speaking.
=This is also Ren speaking
t=Ren is no longer speaking.

This feature makes DVN scripts read more like natural story text, while remaining fully compatible with the legacy syntax.

Notes

  • This system is designed to be forgiving.
  • Small mistakes won't break parsing during development.
  • Logged warnings help catch typos or unintended formatting without stopping execution.

ruby

Allows ruby text display and parsing for a specific scene.

Example:

私(わたし)は日本語(にほんご)を勉強(べんきょう)しています。

And without ruby text:

私は日本語を勉強しています。

Basically you put the ruby text in parenthesis and it will automatically be displayed under the corresponding text.

You can also add the following config to settings.json to allow ruby parsing and display for ALL scenes, without using the ruby keyword.

"displayRuby": true

Example of ruby text rendering:

DVN Ruby Text

You can also control ruby rendering with offsets etc.

This is done in settings.json with the following configurations:

"rubyOffset": 0,
"rubyStartChar": "",
"rubyEndChar": "",
"shadowRuby": false

When not specified the following is the default:

"rubyOffset": 1,
"rubyStartChar": "(",
"rubyEndChar": ")",
"shadowRuby": false

hideDialogue

Hides the dialogue panel.

hideButtons

Hides the dialogue buttons.

Note: This requires the legacy buttons to be turned on.

characterFadeIn / cf

Fades the character in.

stopMusic

Stops the current music.

stopSound

Stops the current sound effect.

fadeMusic

Will fade music in for the scene.

chance

chance=VALUE

Will display either a text node or an option by a given chance.

Example:

chance=50
t=This has 50% chance of being displayed.

background / bg

Displays a background image.

background=VALUE
bg=VALUE

music / m

Plays a music track in the background.

music=VALUE
m=VALUE

Implicit Background/Music in scene headers.

Scene headers allows implicit background/music specifications, so you don't have to specify bg=BACKGROUND and m=MUSIC in the scene body.

Example:

[my-scene] (background, music)

Or just the background:

[my-scene] (background)

Or just music:

[my-scene] (, music)

sound / s

Plays a sound effect.

sound=VALUE
s=value

voice

Plays a voice line.

voice=VALUE

effect / e

Will chain an effect to the scene.

effect=EFFECT
effect:pre=EFFECT
effect:post=EFFECT
effect=EFFECT,VALUES...
e=EFFECT
...

For detailed effect syntax and parameters, see Effects & Transitions.

char / c

Displays a character with either default pose/expression or a given pose/expression.

char=VALUE
char=VALUE,POSE/EXPRESSION
c=VALUE
c=VALUE,POSE/EXPRESSION

To display multiple characters simply specify the character command multiple times.

c=aya
c=ryo
Ryo and Aya will be displayed here.

The above will display both Aya and Ryo in the same scene.

charMovement / cm

Moves a character in a specific direction.

Values: top,bottom,left,right

charMovement=VALUE
cm=VALUE

charMovementSpeed / cms

Defines the speed for the movement of the character.

charMovementSpeed=VALUE
cms=VALUE

charName / n

Displays the given name of a character.

charName=VALUE
n=VALUE

charColor / cc

Defines the color of the character name in hex.

charColor=VALUE
cc=VALUE

charPos / cp

Displays the character at a given position.

This can be a specific position like bottomSlightLeft or a pixel coordination like 150,150.

Values: center,left,right,bottomCenter,bottomright,bottomLeft,topCenter,topRight,topLeft,topSlightLeft,topSlightRight,slightLeft,slightRight,bottomSlightLeft,bottomSlightRight

charPos=VALUE
cp=VALUE

charNamePos / np

Sets the position of the character name.

Values: left,center,right

charNamePos=VALUE
np=VALUE

removeCharacter / rc

Removes a character from the scene.

removeChar=VALUE
rc=VALUE

characterZIndex / cz

Sets the z-index for a character.

characterZIndex=VALUE
cz=VALUE

video / v

Displays a video.

video:X,Y:WIDTH,HEIGHT=SOURCE
v:X,Y:WIDTH,HEIGHT=SOURCE

animation / ani

Displays an animation.

animation:X,Y=VALUE
ani:X,Y=VALUE

label / l

Displays a text label on the screen.

label:FONTSIZE:X,Y:COLOR_IN_HEX=VALUE
l:FONTSIZE:X,Y:COLOR_IN_HEX=VALUE

font / f

Sets the text font.

font=VALUE
f=VALUE

text / t

Sets the dialogue text.

text=VALUE
text:SCENE=VALUE
t=VALUE
t:SCENE=VALUE

act / a

Displays the act view instead of a scene.

act:SCENE:CONTINUE_BUTTON_TEXT=VALUE

option / o

Displays an option.

option:SCENE=VALUE
o:SCENE=VALUE

view

Displays a view

view=VALUE

Variables

Variables in DVN is controlled from D to keep scripts clean from code.

This separation keeps DVN scripts focused on storytelling, while all game logic, values, and state management live in D code.

You can save variable states in your save files.

Basically in your event handler you create your variables and then override the event handlers for saving and loading your game.

import std.conv : to;

private bool hasKey;

public override void loadedGameScripts(SceneEntry[string] scenes, SaveFile saveFile)
{
    if ("hasKey" in saveFile.meta)
        hasKey = saveFile.meta["hasKey"].to!bool;
    else
        hasKey = false;
}

void savingGame(SaveFile[string] saves, SaveFile saveFile)
{
    saveFile.meta["hasKey"] = hasKey.to!string;
}

// Use "hasKey" anywhere else in code.

To use the variable in your code see the examples under Flow Control for conditional branching.

Flow Control

Basic scene switching

It's simple to control your flow in DVN, you simply use the :state syntax to declare a scene-change state on a text node or an option node.

t:next-scene=This will go to the next scene.

For options you can use the [SCENE] -> [TEXT] syntax to create them without writing o:[SCENE]=[TEXT].

It is a much cleaner approach to branching.

Where do you want to go?
scene-1 -> To scene-1!
scene-2 -> To scene-2!

Another way to switch scenes is using the implicit scene switch statements.

This can be either ->, continue, then or next, all representing the same thing.

There is one difference tho, -> does not require the = symbol.

Examples:

->next-scene
continue=next-scene
then=next-scene
next=next-scene

All the above statements do the same thing.

You can also tell DVN to automatically go to the next written scene (in the same file.) using the ~ symbol.

Examples:

->~
continue=~
then=~
next=~

You may also use the * symbol here for flow control meaning insert current module name ex. main.vns has the module name main.

Meaning:

->*-start

Becomes

->main-start

Conditional branching

Conditional branching has to be done through D code because script-writing and programmatically functionality is separated.

So to create conditional branching you must override events where you want the condition to live.

Example:

Script:

[main]
Do you pick up the key?
picked-key -> Yes
no -> No

[no]
You didn't pick up the key.

[picked-key]
t:in-front-of-the-door=You picked up the key.

[in-front-of-the-door]
# We must have a text node here even tho it is ignored ...
# Because the event handler needs a node to anchor
.

[in-the-secret-room]
You have entered the secret room.

Event handler:

import std.conv : to;

private bool hasKey;

public override void loadedGameScripts(SceneEntry[string] scenes, SaveFile saveFile)
{
    if (saveFile && "hasKey" in saveFile.meta)
        hasKey = saveFile.meta["hasKey"].to!bool;
    else
        hasKey = false;
}

void savingGame(SaveFile[string] saves, SaveFile saveFile)
{
    saveFile.meta["hasKey"] = hasKey.to!string;
}

public override void beginHandleScene(ref SceneEntry scene, ref SceneEntry nextScene, bool isEnding, SceneEntry[string] scenes)
{
    if (scene.name == "picked-key")
    {
        hasKey = true;
    }
    else if (scene.name == "in-the-secret-room")
    {
        hasKey = true;
    }
    else if (scene.name == "in-front-of-the-door")
    {
        if (hasKey)
        {
            scene = scenes.get("in-the-secret-room", null);
            nextScene = scenes.get(scene.nextScene, null);
        }
    }
}

You can also do conditional options using events.

Script:

[main]
t:in-front-of-the-door=You walk in front of the door.

[in-front-of-the-door]
What do you do?
open-door -> Open door
stay-away -> Stay away

[open-door]
You open the door.

[stay-away]
You stay away from the door.

Event handler:

import std.conv : to;

bool hasKey;
SceneEntry scene;

public override void loadedGameScripts(SceneEntry[string] scenes, SaveFile saveFile)
{
    if ("hasKey" in saveFile.meta)
        hasKey = saveFile.meta["hasKey"].to!bool;
    else
        hasKey = false;
}

void savingGame(SaveFile[string] saves, SaveFile saveFile)
{
    saveFile.meta["hasKey"] = hasKey.to!string;
}

public override void beginHandleScene(ref SceneEntry scene, ref SceneEntry nextScene, bool isEnding, SceneEntry[string] scenes)
{
    this.scene = scene;
}

public override void renderGameViewOption(Label option)
{
    if (!hasKey && scene.name == "in-front-of-the-door" && option.text == "Open door")
    {
        option.hide();
    }
}
public override void renderGameViewOption(Button option)
{
    if (!hasKey && scene.name == "in-front-of-the-door" && option.text == "Open door")
    {
        option.hide();
    }
}

Conditional chance

You may also use the chance command to display either text or an option by chance.

chance takes a value from 0 to 100, representing a percentage chance that the next text or option will be used.

chance=50
This text will have a 50% chance of showing up.

or

where to go?
school -> To school.
chance=1
# 1% chance of the secret place being possible.
secret-place -> Secret place.

Embedded Expressions

In DVN each character expression is implemented as a character state.

Meaning you declare ex. the following in your data/game/characters.json

{
    "Stickman": {
        "default": "Smiling",
        "Smiling": "...",
        "Sad": "..."
    }
}

Then in your script you just write.

c=Stickman,Smiling

or

c=Stickman,Sad

See DVN Basics for the full syntax.

Comments

Comments in DVN scripts use the '#' character at the beginning of a line.

There are no multi-line comments, and you cannot place comments at the end of a script line.

# This is a comment

Note: The parser ignores comments, so you can't fetch them from code.

Script Best Practices

These optional guidelines help keep your DVN scripts clean, readable, and consistent.

  • Use lowercase scene names without spaces. - Example: [this-is-a-scene]

  • Keep scripts easy to read. - Formatting and spacing matter for long-term maintainability.

  • Prefer short-form commands, unless the meaning becomes unclear in larger scenes.

  • Organize files into the appropriate folders so your project structure stays clean.

  • Keep logic out of narration. - Let the script focus on storytelling—not code behavior.

Extending the Scripting Language

Adding new commands from D

Adding new keywords can be done simply using the event injectGameScript.

bool injectGameScript(SceneEntry scene, string key, string[] keyData, string value);

This function provides:

Parameter Meaning
scene The scene where the command was found
key The command keyword (e.g., note)
keyData Any state modifiers (if present)
value The value assigned to the command

Example: note command:

This example creates a note command that displays a temporary on-screen message.

Script usage:

[main]
note=Tip: You may use 'CTRL' to continue the story.
Welcome!
Let's begin.

Code implementation:

import std.conv : to;

private string[string] _notes;

public override bool injectGameScript(SceneEntry scene, string key, string[] keyData, string value)
{
    if (key == "note")
    {
        _notes[scene.name] = value;
        return false;
    }

    return true;
}

void beginHandleScene(ref SceneEntry scene, ref SceneEntry nextScene, bool isEnding, SceneEntry[string] scenes)
{
    auto note = _notes ? _notes.get(scene.name, null) : null;

    if (note)
    {
        auto window = getApplication().getRealWindow();

        if (!window) return;

        auto view = window.getActiveView!GameView("GameView");

        if (!view) return;

        auto settings = getGlobalSettings();

        auto noteLabel = new Label(window);
        view.addComponent(noteLabel);
        noteLabel.fontName = settings.defaultFont;
        noteLabel.fontSize = 18;
        noteLabel.color = "fff".getColorByHex;
        noteLabel.text = note.to!dstring;
        noteLabel.shadow = true;
        noteLabel.position = IntVector(16, 16);
        noteLabel.updateRect();

        // Remove the note after 4 seconds ...
        runDelayedTask(4000, {
            noteLabel.hide();
            try { view.removeComponent(noteLabel); }
            catch (Exception e) { }
        });
    }
}

Adding custom effects

Adding custom effects is as easy as implementing a simple effect class.

public final class MyEffect : Effect
{
    private size_t _windowId;
    private bool isActive;

    public:
    this()
    {
        class MyEffectEvents
        {
            override void preRenderContent(Window window)
            {
                if (!isActive)
                {
                 return;
                }

                if (window.id != _windowId)
                {
                    return;
                }

                // Do things per frame
            }
        }

         DvnEvents.setEvents(new MyEffectEvents);
    }

    override void handle(string[] values)
    {
        auto window = getApplication().getRealWindow();
        if (!window) return;
        _windowId = window.id;
        auto view = window.getCurrentActiveView();
        if (!view) return;
        auto components = view.getComponents();

        // Configure effect using values here ...

        isActive = true;
    }
}

Custom effects must be registered when the engine is ready using the following event handler.

void engineReady(Application app, Window[] windows)
{
    registerEffect(new MyEffect);
}

Now in your script you can just use the effect command like:

effect=MyEffect

Working with scene objects

Each component has a dataId field that you can use to tell whether it is a scene object or not, and what scene object it is.

Using the following enum will help you distinguish each scene object type.

public enum SceneComponentId : size_t
{
	none = 0,
	background,
	label,
	character,
	characterName,
	image,
	video,
	animation,
	textPanel,
	text,
	option
}

Example:

foreach (component; components)
{
    if (component.dataId == SceneComponentId.character)
    {
        // We only want character scene objects for the effect ...
    }
}

Custom Scripting Language

DVN does not lock you into its default scripting format.
The built-in .vns scripting language exists for convenience, but you are free to replace it entirely if your project requires a different structure, syntax, or workflow.

To implement your own scripting language, override the following event:

void loadedGameScripts(SceneEntry[string] scenes, SaveFile saveFile)
{
    scenes.clear();

    // Parse your custom scripting language here ...
    // And create each scene node here ...
}

Creating Scenes Manually

As long as you populate the scene graph, DVN will handle the rendering, transitions, UI, and flow for you.

Example:

void loadedGameScripts(SceneEntry[string] scenes, SaveFile saveFile)
{
    scenes.clear();

    auto myCustomScene = new SceneEntry;
    myCustomScene.name = "main";
    myCustomScene.background = "Background";
    myCustomScene.text = "This is some custom text.";
    myCustomScene.nextScene = "end";

    scenes[myCustomScene.name] = myCustomScene;
}

Notes

  • You do not need to implement your own rendering system.
  • You do not need to manually run transitions, UI, or text logic.
  • DVN will automatically run scenes you define, no matter where they came from.

This flexibility allows you to build:

  • scripting languages tailored to your game
  • external narrative formats (.json, .xml, .ink, .yaml, etc.)
  • dialogue pipelines imported from tools like Twine, Ink, or spreadsheets
  • proprietary or experimental writing systems