Handling YAML Syntax Errorsπ
What if you make a YAML mistake? How can you find it?
Requirements
Related Docs
- No related documentation
Example YAML Errorsπ
Let me show you an example of a small quest with a few typical YAML errors. You might be able to see that something is off.
Example Quest with YAML Errors | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 |
|
You will notice that two events in the events section are written in green instead of blue.
That's because of a YAML Syntax error.
Do you already see the mistake here? It is simple: There is a colon (:
) missing after
the key giveFishObj
in line 9. Because of the missing colon YAML will fail to parse this file.
But now let's have a look at the same file in VSCode. The YAML Syntax extension will clearly highlight the error:
If you hover over the error, you will see more information:
Whilst these are quite technical and hard to understand, the highlighting will clearly show you where errors need to be fixed.
Let's have a look at the condition !hasEnoughFish
in the conversations part:
This will give us an unresolved tag: ... error because special characters like the exclamation mark (!
)
cannot be written without surrounding (" "
) double quotes.
Another common mistake is to use single quotes to surround a value and then also use it inside the value itself like this:
Instead, the line should be written like this: notifyPlayer: "notify You've completed the quest!"
To prevent those errors we highly recommend to always use double quotes.