Dialogue system
Posted: Fri Apr 03, 2026 6:35 pm
I've been taking a bit of a break from the "core gameplay loop" so next up on the menu working on the lore and creating the area where the metaprogression is gonna happen: The Hub.
But before we reveal any details about the hub (it's a bit of a spoiler
). I've started working on a new dialogue system. So time for a micro devlog!
Dialogue is one of those things that I could over-engineer to no end and end up at Disco Elysium levels of coolness... That'd be really nice, but if I ever wanna get there, I feel it's something for future me to worry about. I want to start simple and expand as needed, so I think something like RPG Maker dialogue system is gonna be best. This is what I have, for now: Other than a reminder that my little UI library is cool and some appreciation for FontStashSharp's rich text mode, there wasn't really much to displaying the dialogue itself.
Storing the dialogues, however, was a bit more interesting.
Carrot Survivors had the dialogues embedded in code. But for this time I wanted to experiment with something a bit easier to author, so my first instinct was to develop a little dialogue scripting language, with a custom handwritten parser. Like most people who were infected by the langdev virus, I have this urge to get my fix by writing a tiny parser from time to time... And I was about to do that, so I started researching to see what kinds of languages people were using to store in-game dialogues. Then I stumbled upon this:
Keep in mind I skipped reading the question (a bit of a bad habit of mine), and I stopped reading after the first sentence of the answer, the one I highlighted.
I only needed those words, and I was defeated. Langdev zoomies dead on the spot.
The ominous music rang inside my head:
Now I remember! I was lost in the sea of human souls.
Wrangler of the pom, beacon of the enterprise. You can call me Duke.
From henceforth, I am at your service. For I am thou, and thou art I.
Of course it's hypertext. It's always hypertext isn't it? XML fit every criteria I had for this little dialogue scripting language:
- Allows defining basic structure: A dialogue is a list of commands, commands allow setting the character and the portrait, display a text, display a bunch of choices, set a variable... Different commands have different parameters and some commands contain messages.
- Inside messages, I need good support for mixing plain text and other kinds of metadata. I have implemented color for styling already, but I also have ideas to embed custom commands in the middle of the text. For example, to set text speed, play sound effects or read variables (like the player's name).
My plan is not to add all the features I listed here for this game. But I like to make the thought exercise early on to know if this is gonna be a system that can grow with me, hopefully in future games!
Implementation-wise XML simplifies things by a lot. The parser is already there, every language has an XML parser. Not the simplest language and not the cheapest to parse by far, but it's just a bunch of dialogue. Anyone who obsesses about the memory usage of parsing a bunch of dialogue lines should try writing one (1) megabyte of text just to get a sense of how silly worrying about memory in this scenario is.
Another great point in favor of XML is people are already familiar with it. I'm not going to be doing the bulk of the writing (hi Kathee!
), so optimising this language for myself would be silly. I don't want to be fixing bug reports for the dialog language parser
. Plus, these files may be handed off to other translators too, and I'll risk my XKCD#2501 status to say the average person is already familiar with XML (via HTML, if nothing else), and CSS of course (of course!).
XML also saves me a bunch of work on the tooling front. Tooling for XML is not excellent, but it's adequate. My editor already has syntax highlighting and auto-formatting for XML. It wouldn't be hard to add squiggles based on XML-Schema which would get me 80% of an LSP at 1% of the cost. Great tradeoff!
Anyway, XML! This is the XML dialogue from the clip above. Writing the "parser" for this, plus the UI bits and snippets took a few hours over the last couple days, so I'm very happy with the experiment. Now, time to add some lore into the game!
But before we reveal any details about the hub (it's a bit of a spoiler
Dialogue is one of those things that I could over-engineer to no end and end up at Disco Elysium levels of coolness... That'd be really nice, but if I ever wanna get there, I feel it's something for future me to worry about. I want to start simple and expand as needed, so I think something like RPG Maker dialogue system is gonna be best. This is what I have, for now: Other than a reminder that my little UI library is cool and some appreciation for FontStashSharp's rich text mode, there wasn't really much to displaying the dialogue itself.
Storing the dialogues, however, was a bit more interesting.
I only needed those words, and I was defeated. Langdev zoomies dead on the spot.
Now I remember! I was lost in the sea of human souls.
Wrangler of the pom, beacon of the enterprise. You can call me Duke.
From henceforth, I am at your service. For I am thou, and thou art I.
Of course it's hypertext. It's always hypertext isn't it? XML fit every criteria I had for this little dialogue scripting language:
- Allows defining basic structure: A dialogue is a list of commands, commands allow setting the character and the portrait, display a text, display a bunch of choices, set a variable... Different commands have different parameters and some commands contain messages.
- Inside messages, I need good support for mixing plain text and other kinds of metadata. I have implemented color for styling already, but I also have ideas to embed custom commands in the middle of the text. For example, to set text speed, play sound effects or read variables (like the player's name).
My plan is not to add all the features I listed here for this game. But I like to make the thought exercise early on to know if this is gonna be a system that can grow with me, hopefully in future games!
Implementation-wise XML simplifies things by a lot. The parser is already there, every language has an XML parser. Not the simplest language and not the cheapest to parse by far, but it's just a bunch of dialogue. Anyone who obsesses about the memory usage of parsing a bunch of dialogue lines should try writing one (1) megabyte of text just to get a sense of how silly worrying about memory in this scenario is.
Another great point in favor of XML is people are already familiar with it. I'm not going to be doing the bulk of the writing (hi Kathee!
XML also saves me a bunch of work on the tooling front. Tooling for XML is not excellent, but it's adequate. My editor already has syntax highlighting and auto-formatting for XML. It wouldn't be hard to add squiggles based on XML-Schema which would get me 80% of an LSP at 1% of the cost. Great tradeoff!
Anyway, XML! This is the XML dialogue from the clip above. Writing the "parser" for this, plus the UI bits and snippets took a few hours over the last couple days, so I'm very happy with the experiment. Now, time to add some lore into the game!