Skip to content
On this page

Config files

Config files are all written in yaml by default, though you can also use json (this is not encouraged).

Introduction

A narrat game needs a few config files to function: The main config.yaml is where a lot of settings are configured, and characters.yaml is where the various characters that can speak in the game are setup. On top of that, there are config files for specific features (like items.yaml or skills.yaml).

Split config or embedded config in config.yaml

It is possible to put the config of those other files like items.yaml directly in the main config.yaml, but this is not encouraged and will probably be deprecated in the future. The narrat template already comes with feature-specific separate config files, which is much easier to use and understand than a single giant config file.

There are example files available:

example-config.md

Editing the config

By default config.yaml should be in public/data. If you want to change its position, edit src/index.ts to have the correct path to your new localisation.

The config.yaml file is a yaml file which should already contain everything necessary if using the template, but some optional values can be omitted. For an example config file, look at the example configs page. It may also be relevant to look at other yaml files in the example games.

Other config files

Many parts of config.yaml list a path to another .yaml file. This is to separate config into manageable chunks where you only edit the file relevant to a feature (like skills.yaml, or items.yaml).

The various features and guides sections of this documentation can give more information about how to use each option.

TIP

The examples folder of narrat contains the config for a bunch of example games, which can help you discover available options.

Validation

Config files are validated by the engine. This means when running the game, the engine will show error messages explaining any missing or incorrect values in config files. This ensures configuration files are always correct.

Config options

There are many possible options in the config. They are not currently all documented, but the documentation for a specific feature often shows or explains the relevant config.

Finding out possible config options from the source (advanced usage)

More advanced use: To see the exact definition of config files and their options, look in the config folder of the engine code. This is where all the possible config options are defined in a json-schema format. This is harder to read, but it is the actual source that defines the possible options in the code, and is likely to be the most up to date way of finding out possible options.

For example:

ts
export const ObjectiveDataSchema = Type.Object({
  description: Type.String(),
  hidden: Type.Optional(Type.Boolean()),
});
export const QuestDataSchema = Type.Object({
  title: Type.String(),
  description: Type.String(),
  objectives: Type.Record(Type.String(), ObjectiveDataSchema),
});

This quest config means a quest has the following properties:

  • title: A mandatory string value
  • description: A mandatory string value
  • objectives: A key-value list of objectives defined in the ObjectiveDataSchema

Then, an objective config has:

  • description: A mandatory string
  • hidden: An optional boolean value

How the config works

The engine follows this process for loading the config:

  • Each config section has a default config. This default config exists to provide default values to options that don't need to be changed by default
  • The engine loads the game's config files. Those are the files coming from the game itself
  • Each default config is merged with the game's config so that whatever the game customised overrides what's in the default options

Characters config

Additionally to config.yaml, there is a separate characters.yaml file containing the config for all characters in the game.

See more info at the characters and portraits guide

Other config files

There are individual config files for most narrat features which you can edit. The best way to learn about them is to look at example games and see how they are used.

Released under the MIT License.