2025-Mar-28, Friday

dorchadas: (JCDenton)
Insert that quote about how "I'm a content creator--I create problems for myself."

If you know anything about JSON, you might think "refactor JSON? What are you talking about?" If you don't, JSON is a way of storing data that makes it easy for both machines and humans to read. It's all done as key-value pairs, so you have like
"name": "Item",
"Description": "This is an item.",
"black": true
and so on and so on, with as many fields as necessary.

The reason for the refactor is that Cataclysm: Dark Days Ahead has a JSON-based scripting language incorporated into it. A lot of games use Lua for modding, a programming language where one of its main feature is that it's designed to be embedded in other codebases (such as that of a video game), and indeed some other forks of Cataclysm use Lua as well. CDDA does not, for several reasons, but as far as I know the most relevant is that it's open source, multiple builds come out every day, and the Lua integration would need constant work and constant tweaks to keep working with all the changes. A full game that releases discrete patches can make sure all the Lua binds are working before releasing the patch, thus avoiding constant mod disruption.

Anyway, CDDA has a scripting language called "Effect on Condition" that's all built out of the dialogue system, which allows certain dialogue choices to only appear sometimes depending on what Conditions are set--what other quests you've done, how long since the start of the game, if you have certain items, etc.--and cause an Effect, like setting NPC opinions, giving you quest rewards, and so on. That was all expanded out to scripts that run under certain Conditions and cause certain Effects. Nowadays a lot of the game is reliant on this system for more complicated effects, since it's easily expandable and testable without re-compiling the game, which lowers the barrier for contribution. One update allowed crafting recipes to run a script on completion, and I used this to make training psychic powers for my Mind Over Matter mod into crafting recipes. At the time, I did not have the skill to come up with a generic framework, so every single recipe (something like 200) had individual handling for training whatever power it is attached to.

Well, this week I pulled the trigger and rewrote every one of those 200 scripts so they all called on a set of ten total scripts, nine for each of the psionic paths (telekinesis, telepathy, etc), and then a final one that handles which power you're using and appropriately trains it. That means if I ever want to make changes in the future, I only to do it at most ten times, and more probably only one time, rather than having to mirror the change 200 times and hope that I never mess it up. It only took like six hours to go through thousands of lines of JSON and make all the changes, but now it's all done and easy to make further changes. I'm already thinking of how to make learning powers a bit more complicated--currently it's a straight Skill + 1d10 vs a difficulty roll, and when that was repeated 200 times I was loathe to change it. But now that I would only have to change it once...

The eternal battle between "add new things" vs. "do boring work of making old thing better" and this time the second one won.