Creating a scripting language for a Visual Novels

This article will be the first of a series and will be written alongside my project. Preliminary to this post, I’ve played for quite some time with Godot and made some little Engine for writing Visual Novels (VN). I later reworked it, integrating some patterns I’ve observed into GDQuest course that I bought earlier. Everything worked as expected, but editing each Scene was a lot of repetitive work. I needed some little scripting language or a plugin to speed things up so I went researching.

First I looked at well-known Ren’Py, but I find putting indentation in the middle of your writing really horrendous. Worse, perusing VN game devs forums, I would see that it was common practice for writers to hire a programmer to translate their script to Ren’Py or write a script that would do it for them. I’ve then taken a look at Ink, the scripting language of Inkle, on the advice of an ex-colleague of mine and it’s nearly what I want. There are even some godot plugins for it, godot-ink and ink-gd. However it’s not much more readable, and it seems written more for textual adventures than VN with a bit of gameplay. So I decided the crazy thing to create my own scripting language and lose a lot of time that I could use to actually make games. It’s going slowly, mostly because I have never done that before and I have a lot of research to do about it.

The language

I want my scripting language to read like theater/cinema blocking. You should be able to set up the scene at the top of the document and read through it like any normal human. I aim to serve a writer/programmer that wants to keep code away from its writings or a team of a programmer and a writer. My idea of what it would look like is this:

---
# This is a comment
# In this section we declare the variables. 
# Those variables are exisiting custom made Godot resources that will be loaded
# via a singleton (basically a library of resources)
House_Interior # A background for the scene
Alice          # Character used
Bob
answer bool    # Declare a variable that will be used in conditions.
---

Alice appears left 
# This will trigger a godot event called appears, with Alice as first argument and
# left as second. 
Bob appears right 

Alice - How are you today ?  # Just dialogue, our main feature.
Bob - Pretty good thank you!
Alice - Do you come tomorow ?

I aim to have this working pretty quickly, because the tree will be completely flat.

Even though I have a big dislike for writing any sort of scripting in the middle of this, it is necessary that I implement a simple system that allows writer to trigger a choice and write some dialogues with it without programmer help. Anything complicated would just go through sending events to the Scene in Godot.

# I intend following snippet to display a choice to user and populate the 
# variable with corresponding value

Choice answer {            
Yes it will be terrific!  
True
No I'm sick.
False
}

# Here we have conditional execution

If answer == True {
Alice - Cool, see you tomorow !
}

If answer == False {
Alice - Oh Bummer! I was looking forward to see you
}

The progress

This will require much more work. So far, I’ve written a parser that read through the file and create little tokens such as “String”, “Newline”, “Operator”, “EndOfStatement”. I’m discovering along the way so it’s a bit exciting. I’ve been warned to keep any higher logic out of the parser but I think I already sinned. During the parsing, I parse the declared variable as “Actors”, so it would be picked up and create an “Actor” Token.

I made timid efforts to build the tree and connect it to the engine but this will be in a further post!

Wanna give me advice, comment, or tell me I’m a fool? Contact me at daphnee.portheault@protonmail.com