I thought I’d start one of these blog things. I’ll be using them to announce... things. First up is the release of a mod that’s five years late.
Veterans of the LucasForums era may remember a mod for Star Wars: Knights of the Old Republic II – The Sith Lords called “JC’s Toolbox”. It added what I called “a collection of items for developers, filmmakers, and cheaters of all kinds”. It let you do things like open and close doors, get free items and XP, teleport, spawn characters, and play animations, and it granted full control over the party system so you could add or remove party members wherever and whenever. I initially sought out these functions while making videos with the game, and also found them to come in handy with mod development.
Before I made the Toolbox, I relied on a few different mods - the Whereami Armband, Call of Aid, Teleporter 2000, and the Wrist Console - to perform these functions. Most of these mods performed their function through armband items; you could equip the armband on your player character, and then it would fire the mod’s script when activated. The Wrist Console was a little different, using Mira’s wrist launcher as a template instead. But they all gave you an item that, instead of creating an energy shield, would fire a custom script to teleport you or spawn characters or whatever. I even made my own edits to a couple of these mods, adding more features like animations and unused camera modes that were left over from Neverwinter Nights. I used these for years before deciding to learn how to make a proper armband myself instead of hacking someone else’s.
In the process, I also learned that armbands and wrist launchers weren’t even necessary: there’s an unused item type called “Plot Usable Item” that functions like an armband, but the function is available so long as the item is in your inventory. You don’t have to equip it at all. I believe this was used for the sonic device on the water suit in the first game, the one that lets you kill sharks. It still functions in KOTOR II, and since you don’t need to equip it to use it, I could access more than two of them at a time. The entire party could access them, too. That was much more convenient than the previous setup. So I decided to rebuild not only my mod hacks, but also many of the original functions of those mods, to give myself a set of Plot Usable Items to replace all the old tools.
With accessibility being a non-issue, I decided to make several tools, each with a limited scope. My hack of Call of Aid had gotten particularly crowded, so I wanted to avoid that. Each new tool would specialize in a specific area, such as spawning characters, playing animations, or managing the party system. And I overdid it. The initial release of JC’s Toolbox contained eighteen usable items. I ended up making the actual Toolbox item just to be able to fire the other seventeen from the same place.
According to my records, I released the K2 version of my Toolbox in December 2012, and over the following year I made a couple updates to that. I didn’t release a K1 version. There was a good reason for that. A bunch of my scripts wouldn’t work. It took me five years to figure out why.
I was never compiling scripts for K1.
It’s rather embarrassing, but that’s that’s the truth of it. I compile my scripts through a batch file, and I have a different one for each game. When I first set up the K1 compiler in 2009, I neglected to edit the file to change the game number. On top of that, I wasn’t aware of some significant differences in scripting for each game. I knew Obsidian added many functions, but I didn’t realize they had changed a few of them too - common functions like ActionStartConversation, DestroyObject, and CreateItemOnObject. Several functions have been altered to pass more parameters in K2. For example, when creating an item in K2, you can specify whether the player will be alerted through the GUI or whether the creation will be hidden. I first learned how to script in K2, and you could say I developed some bad habits and wrote all my K1 scripts under the assumption that they worked the same as they did in K2. And because both my compilers were set to compile for K2, I was never told otherwise. No error messages, no scripts that wouldn’t compile, nothing. The compiler was reading K2 scripts and writing K2 scripts, so as far as it was concerned, nothing was wrong.
For nine years, I was writing scripts for the wrong game.
For the most part, these scripts did work. I’m amazed how much of it did work. Even though the scripts were compiled for the wrong game, even with the differences in those functions, they did run. After all, I wouldn’t have gone so long without noticing the problem if the scripts didn’t work. I’m only now realizing how many oddities I encountered can be blamed on this mix-up.
Up to a point, my scripts would run properly. Even if my script was compiled for the wrong game, most of the functions are the same, so it was happy. Then it would reach one of these functions that Obsidian had changed. It would get to an extra parameter that didn’t belong in K1. That’s where the trouble began.
With CreateItemOnObject, the parameters are the item name, the object to receive the item, the number of items to create, and then whether to hide this process or not. In K1, the script was happy to put in the item, and the object, and the amount, but when it got to that last bit, it couldn’t take it anymore. The function wasn’t coded to allow a fourth parameter. So it would execute the first three parameters, and then it would get stuck. That meant it would actually create the item, as I intended. But the rest of the script wouldn’t run. Not just the rest of that function, but the rest of the entire script.
That’s how these bugs would play out. My script would run up to a point, and then mysteriously stop running. It all makes sense to me now, but understand that for years and years, I didn’t have any reason to assume there was a connection between these oddities, or that they could all be blamed on such a simple mistake. As far as I was aware, they were isolated incidents beyond my control. I thought that was just the way things were, and developed some workarounds, like executing CreateItemOnObject in a separate script, that let me do things the wrong way for nine years.
And even doing things the wrong way, I still managed to achieve most of what I wanted. But these bugs crippled the Toolbox for K1. I started working on it shortly after the initial release of the K2 version, but certain scripts just would not behave. I released a few betas of the K1 version that lacked the misbehaving features, but I held off on an official release until I could get them to work. I could never figure that out. I only realized my compiling issue recently, by happenstance, and from there I was able to unravel the whole mess. It was all because of a stupid mistake that was Past JC’s fault.
Now, JC’s Toolbox for K1 is ready for release. It’s a collection of items for developers, filmmakers, and cheaters of all kinds. It lets you do things like open and close doors, get free items and XP, teleport, spawn characters, and play animations, and it grants full control over the party system so you can add or remove party members wherever and whenever. It’s five years late, but it works. And it was programmed for the right game.