Afforess
The White Wizard
It's rather easy to add new columns to XML tables (like Technologies), which can be used Firaxis columns. At the moment, all attempts to add new XML columns via pure XML have failed, but it works with SQL. These new columns can be accessed from the DLL (if you had source code access... ) or from Lua.
Assuming you've already got a project set up in Modbuddy, add a new SQL file. For the purposes of this tutorial, I'll be modifying technologies to add a column for my Tech Diffusion mod, but you can add anything you like to any existing table, so long as you know the datatype you want to use, and the proper name of the table.
In my case, I start with this first line:
We're telling the game that we are altering the Technologies table. Make sure you get the table name exactly correct, or else you will encounter strange issues.
Next, we're giving the table the name of the new column, and datatype.
My new column will be appended to the end of the list, and be named "DiffusionModifier". It's of type integer.
Now, the column is created, but the values are all undefined. You will want to initialize them to whatever default value you want. In my case, I want to initialize them to zero.
Great, now all Technologies have a new column, DiffusionModifier, which is 0. You can use the "WHERE" command in SQL to make your changes more specific, and manipulate the data in any way you see fit.
So far, this new column is meaningless. Let's change the values in SQL. I want modern techs to diffuse faster, so let's add this new line to change modern techs:
Now all techs in the Modern Era have a DiffusionModifier of 25, and you didn't hardcode a thing! Your CS professors would be so proud.
The full SQL file so far is this:
Now, to actually something with your new column. Since DLL access is out of the question, we can't use it there. But we can access it in Lua easily.
Let's say I want to access the new DiffusionModifier for my Tech Diffusion mod. I simply use this new code in Lua
in my code and in Firetuner, it will print out the diffusion modifier of each tech. Hopefully you added the new column for more than just debugging statements though.
Assuming you've already got a project set up in Modbuddy, add a new SQL file. For the purposes of this tutorial, I'll be modifying technologies to add a column for my Tech Diffusion mod, but you can add anything you like to any existing table, so long as you know the datatype you want to use, and the proper name of the table.
In my case, I start with this first line:
Code:
ALTER TABLE Technologies
We're telling the game that we are altering the Technologies table. Make sure you get the table name exactly correct, or else you will encounter strange issues.
Next, we're giving the table the name of the new column, and datatype.
Code:
ADD DiffusionModifier integer;
My new column will be appended to the end of the list, and be named "DiffusionModifier". It's of type integer.
Now, the column is created, but the values are all undefined. You will want to initialize them to whatever default value you want. In my case, I want to initialize them to zero.
Code:
UPDATE Technologies SET 'DiffusionModifier' = 0;
Great, now all Technologies have a new column, DiffusionModifier, which is 0. You can use the "WHERE" command in SQL to make your changes more specific, and manipulate the data in any way you see fit.
So far, this new column is meaningless. Let's change the values in SQL. I want modern techs to diffuse faster, so let's add this new line to change modern techs:
Code:
UPDATE Technologies SET 'DiffusionModifier' = 25 WHERE Era = 'ERA_MODERN';
Now all techs in the Modern Era have a DiffusionModifier of 25, and you didn't hardcode a thing! Your CS professors would be so proud.

The full SQL file so far is this:
Spoiler :
Code:
ALTER TABLE Technologies
ADD DiffusionModifier integer;
UPDATE Technologies SET 'DiffusionModifier' = 0;
UPDATE Technologies SET 'Cost' = Cost * 1.77 WHERE Era = 'ERA_MODERN';
Now, to actually something with your new column. Since DLL access is out of the question, we can't use it there. But we can access it in Lua easily.
Let's say I want to access the new DiffusionModifier for my Tech Diffusion mod. I simply use this new code in Lua
Code:
for eTech in GameInfo.Technologies() do
print(string.format("Diffusion Modifier for %s: %d", eTech.Type, eTech.DiffusionModifier));
end
in my code and in Firetuner, it will print out the diffusion modifier of each tech. Hopefully you added the new column for more than just debugging statements though.