# Creating your mod: The Dialogs editor

The Dialogs editor is used to create and edit the story chapters. These are `.scene.json` file and the base game's files are located within the `scenes/story` folder.&#x20;

There is a lot to this system, so I recommend loading one of the base game's chapters in the editor and then playing the chapter in question to see how what happens on the screen is done in the editor. You can then look at the example mod to see how to register a new story chapter.

{% hint style="info" %}
If the editor is on the same scene that is currently being played by the game, it will follow the execution of the scene node by node
{% endhint %}

## Usage

### Controls

#### Editor

***

**Zooming**

Use the mouse wheel to zoom in/zoom out the editor

**Moving around**

To move around the editor, either use the arrow keys or move your mouse while clicking any blank area of the editor

#### Nodes

***

**Creating nodes**

Either press `Space` or right-click to open the node creation menu

**Deleting nodes**

Either press `Delete` to delete the selected nodes or right-click a node => "Delete"

**Selecting multiple nodes**

Click different nodes while holding `Ctrl` to select multiple nodes at once

**Moving nodes**

Simply hold left-click on a node and move around your mouse to move the selected nodes

#### Comments

You can rename comments by right-clicking them

**Framed comments**

Use `Shift + F` to create a framed comment encasing all the selected nodes

**Inline comments**

Use `Shift + C` to create an inline comment

**Editing comments**

Right click a comment to edit it

**Deleting comments**

Press the `Delete` key to delete the selected comments

### Misc editor info

#### Node buttons

Each node has one or more buttons, when clicked, the buttons open a window letting you configure the nodes's type-specific settings. If the button has a blue background instead of a white background, that means the primary settings are filled and thus the node is usable. Nodes whose primary settings are left blank yet still connected to the dialog tree will be skipped in-game.

#### Loops

It is possible to create loops by connecting a node's output to the input of a previous node or even the same node, however please always make sure that getting out of the loop is possible.

#### Multiple connections

It is recommended to avoid connecting a node to multiple different nodes. The interpreter will not reject it however, and in the case of such a branching path, a path will simply be randomly selected among all the connections.

#### JavaScript fields

Every JavaScript field that needs to return a value *must* use the `return` statement as fields are evaluated as functions.

#### Functions

Function nodes are unique in behaviour, they essentially allow for the creation of a second tree within the same file. The `Tree Jump` node allows you to execute another tree and potentially resume execution of the current tree afterwards; The `Function Start` and `Function Call` nodes serve a similar purpose. You can use them to create a series of reusable actions, that can be executed whenever you want within the main execution flow of the tree.

First, start by creating a `Function Start` node. This node cannot be connected to the rest of the tree and exists independently. After giving a name to the function, you can connect any node (including a `Function Call` node) to this node and create a series of reusable actions you can execute at any moment.

Within the main tree, you can then use the `Function Call` node to "call" the function you created earlier, the function's nodes will be executed as if they were their own tree, before resuming execution where the `Function Call` node that made the call is.

## Modding story scenes

Once you are done setting up your scene, create a `scenes` folder at the root of your mod (where your mod's descriptor is) and a `story` folder inside it. Then, save your scene file inside it. The extension MUST be `.scene.json`

As long as your scene file is within this folder (regardless of whether it is within subfolders), it will be automatically loaded when your mod is loaded. However, scripting is needed to actually make it playable. For that, check out the example mod's `js/scene-registering.js` file
