inside 338 collectible manuscripts,
each translated to 8 other languages!
An average game is probably somewhere in the middle.
The latest game I worked on has around 4,300 words.
So how do games manage all that text? How is it structured? Where is it stored? How was it drafted?
I was curious... because I'd always been lazily sticking text directly in my games' code!
if (Player.Pressed(Button)) ShowMessage("Something like this.");
This "hard-coded" approach can only go so far, and last year I was reaching my limit. I wanted my little engine to have some better ideas...
The Shoestring Strategies
| Get it? |
The problems only arise once you accumulate too much writing and want to perform operations on it. Operations like... translating to a new language, or asking a non-programmer to edit the messages. How will you gather each scene's dialogue and strip away the code? How long will it take you to incorporate the writer's changes back in? Did you miss a spot? And so on.
| This and back, times a thousand, would really add up. |
It's possible your engine of choice already has a good system for managing text, or maybe these tasks will never bubble up enough to cause any trouble.
Still, as my homemade projects grow, I'd like to avoid any tedious chores or big "oopsie" moments later on.
So the next step might be using external data files, perhaps with a hand-typed structure like json, csv, ini, xml, toml, yaml, etc.
Since these files isolate the writing into a dedicated location, a programmer can easily process just the text in various ways, like reformatting it or measuring the word count. In theory even non-programmers could get involved, so now you have writers writing, translators translating, and voice actors voice acting.
With that, many games could comfortably stop here!
...But my thoughts still weren't settled.
Take a moment to imagine placing game data, like images and sounds, directly inside the source code. Not as text or numbers, but in their natural forms. Like, what if some programming language out there is made of colored pixels, and you write your logical flow with a pencil tool! Then we'd probably end up embedding little images instead of words in our source files.
It just so happens that code and text usually share the same representation, so it's all too tempting to let them intermingle in the same editor screen. That's all that's happening, right?
Or... is there something more going on, something inherent to text that sets it apart?
Is Text Actually Just Text?
We've chosen external data files for the moment, but what exactly are we extracting from the code? Just any "strings" of text that may appear to the player?
That could work, but we'll need to link them back to the code somehow. Maybe we give them all labels, as in key-value pairs. In other words, the code asks for "welcome_hero_to_village" (key) and then receives "Welcome to our village, Hero!" (value) from the database, at least when playing in English.
Those labels take extra effort to manage, especially if we use a key-naming scheme like "area1_scene3_line5" to automate the order. So we'll probably have to build custom tools to organize all our keys, which could be a bit of a chore...
Ah, but there's a bigger problem! Between each line of dialogue in most games there might be pauses, reaction animations, musical cues, camera swoops, inventory updates, conditional branches, and maybe even a dragon flyby or two. These things aren't text! And yet there they are, inseparably linked to that text, interwoven through each passage...
The Dilemma
Where do you think those in-between events and descriptors should reside:
with the game code or with the text?
On one hand,
to split one timeline into two different views could get awfully confusing, as you'd have to keep each side in sync. Clearly these types of moment-to-moment controls should simply go alongside the text in the external data files, right?
On the other hand,
we're referencing extremely game-specific mechanics. How could an external data file check on e.g. the scene's current weather to say the matching line? Clearly we should let that type of game logic stay in the game code and request lines as needed, right?
It almost seems like code and text can't always be cleanly separated. Despite focusing on pure text, we've started converging on a slightly different paradigm, one that emerges from the very nature of text, a kind of glue that holds it together. Since text usually flows in order through time... that means the context and presentation may change along with it...
Which means what we're actually looking for is a story-telling or narration format!
Existing Solutions
With the correct realm identified, let's check out what others have accomplished here. Most of the tools below will let you build shareable, playable games with no coding necessary, so maybe you have a fun weekend project ahead! Let your creative juices flow! I'm not affiliated and didn't end up using any of these, but I'll still list what I found.
First up are open-source solutions. These focus on syntax-based specifications for writing your text files, alongside free or paid supporting software to bring those formats to life.
- Yarn Spinner (<-- currently growing fast!)
- Ink
- Twine
- Ren'Py
- Inform
While the above designs don't quite fit my particular style or requirements, I think they're very cool in their own right and worth checking out.
There are also some paid solutions, which aim to have accessible and featureful user interfaces. While I can't speak to their quality, these seem to be the popular ones:
I want to avoid making developers buy 3rd-party tools just to use my game engine, so I had to rule these out at a glance. Again, your needs may be different from mine.
Not listed: Proprietary solutions, and anything else I missed! Let me know what else is out there.
The Journey Continues
I have my reasons for not choosing any of the above options. For example, several of them treat localization as an afterthought. That strikes me as so odd! I wanna be able to translate my games someday! Past that, I honestly might just be too stubborn or picky about what I add into my game engine.Regardless, in January 2025, I set off designing my own proprietary narration format. It took about 3 weeks in my spare time, and it's been a core part of NME's game development process ever since. In the next post, I'll share this format's standout features and how I arrived at them.
~ Troid92




No comments:
Post a Comment