-
Notifications
You must be signed in to change notification settings - Fork 2
Yaml Syntax
This page provides a basic overview of correct YAML syntax, which is how Bane Of Wargs plugins or vanilla game data are expressed.
We use YAML because it is easier for humans to read and write than other common data formats like XML or JSON. Further, there are libraries available in most programming languages for working with YAML.
Each item in the list is a list of key/value pairs, commonly called a “hash” or a “dictionary”. So, we need to know how to write lists and dictionaries in YAML.
There’s another small quirk to YAML. All YAML files (regardless of their association with Bane Of Wargs or not) can optionally begin with ---
and end with ....
This is part of the YAML format and indicates the start and end of a document.
All members of a list are lines beginning at the same indentation level starting with a "- " (a dash and a space):
---
# A list of tasty fruits
- Apple
- Orange
- Strawberry
- Mango
...
A dictionary is represented in a simple key: value form (the colon must be followed by a space):
# An employee record
martin:
name: Martin D'vloper
job: Developer
skill: Elite
More complicated data structures are possible, such as lists of dictionaries, dictionaries whose values are lists or a mix of both:
# Employee records
- martin:
name: Martin D'vloper
job: Developer
skills:
- python
- perl
- pascal
- tabitha:
name: Tabitha Bitumen
job: Developer
skills:
- lisp
- fortran
- erlang
Dictionaries and lists can also be represented in an abbreviated form if you really want to:
---
martin: {name: Martin D'vloper, job: Developer, skill: Elite}
fruits: ['Apple', 'Orange', 'Strawberry', 'Mango']
These are called “Flow collections”.
You can also specify a boolean value (true/false) in several forms:
used_key: true
showed_dialog: yes
closed_game: false
finished_mission: no
Use lowercase ‘true’ or ‘false’ for boolean values in dictionaries if you want to be compatible with default yamllint options; even if yes
and no
can still be used.
Values can span multiple lines using | or >. Spanning multiple lines using a “Literal Block Scalar” | will include the newlines and any trailing spaces. Using a “Folded Block Scalar” > will fold newlines to spaces; it is used to make what would otherwise be a very long line easier to read and edit. In either case the indentation will be ignored. Examples are:
include_newlines: |
exactly as you see
will appear these three
lines of poetry
fold_newlines: >
this is really a
single line of text
despite appearances
While in the above > example all newlines are folded into spaces, there are two ways to enforce a newline to be kept:
fold_some_newlines: >
a
b
c
d
e
f
Alternatively, it can be enforced by including newline \n characters:
fold_same_newlines: "a b\nc d\n e\nf\n"
Let’s combine what we learned so far in an arbitrary YAML example. This really has nothing to do with Bane Of Wargs, but will give you a feel for the format:
---
# An employee record
name: Martin D'vloper
job: Developer
skill: Elite
employed: True
foods:
- Apple
- Orange
- Strawberry
- Mango
languages:
perl: Elite
python: Elite
pascal: Lame
education: |
4 GCSEs
3 A-Levels
BSc in the Internet of Things
That’s all you really need to know about YAML to start reading Bane Of Wargs wiki pages.
- Running The Game
- Gameplay Guide
- GitHub Discussions
- Building Source Code
- Game Preferences
- The Game Folder
- The World Of Bane Of Wargs
- Game Timeline Plot
- Yaml Syntax
- Creating Mods
- Creating Starts
- Creating Map Points
- Creating Enemies
- Creating Enemies Categories
- Creating Map Zones
- Creating Items
- Creating Drinks
- Writing Dialogs
- Creating Missions
- Creating Events
- Creating NPCS
- Creating Mounts
Additional Knowledge