Question

Sure, you can add a new table. It just won't DO anything; you'll need to make your own Lua code to process it.
 
That's even for existing ones from CIV5Buildings and CIV5Policies? I wanted to copy and paste tables from CIV5Policies and CIV5Buildings to make more interesting traits for my upcoming civs.
Besides, could you give me the name of that file so i can use it as a template?
 
That's even for existing ones from CIV5Buildings and CIV5Policies?

If you mean "I want to copy a stub from a table in the Buildings/Policies file into a table in the Traits file", then yes, even for those. If it's not already in the table definition for that particular table, you can't do it. The fact that table X has an ability in no way implies that table Y can gain the same ability.

Besides, could you give me the name of that file so i can use it as a template?

What file? If you want to add a new table, the syntax is right up at the top of all of the existing files. Just declare a new table in the exact same way. It just won't do anything, because the game engine won't have any knowledge of its existence. You CAN parse your custom table through Lua, in the same way you use variables from any other table. But Lua has a lot of other limitations, and isn't something you should be doing if you're just getting started.

In my own mod, I've created three or four new tables for use by my Lua code. But it can ONLY be used by my own Lua code.
 
Don't be too discouraged; first of all, when the DLL is finally released, it shouldn't be too hard to find the code dealing with a given stub and duplicate it for use with a different table. But even before then, there are occasionally ways to do something sort of like what you want:

Go look at the wiki's page on Lua game objects, specifically the 8 Classes, the Map/Game/PreGame static methods, and most importantly, the Events and GameEvents triggers. This can tell you what's currently possible in Lua.
So if you go into the Player structure and see that there's a function for gaining free policies (ChangeNumFreePolicies), then you know that you could create a <NumFreePolicies> sort of line on any table you wanted, simply by tying it to that Lua. You could make it so that building a certain building gives a free policy, or building a certain unit gives a free policy, or launching a spaceship gives a policy, or whatever. Some of these (like buildings) already have a stub for these, but others don't.
The problem with doing this is the trigger. The current Lua is a bit limited on the triggering events; there simply isn't a "when a unit is completed" event, so if you wanted to make this free policy awarded upon unit completion, it won't work. There's a SerialEventUnitCreated function that triggers when a unit is created, but it also triggers when several other things happen (embark, disembark, air unit rebasing, reloading an old savegame). So this isn't easy and often won't work well.

If you want a trait to give an effect that a building has, the easier thing is to attach the effect to the UB for the same civ that gets that Trait. This sort of intermediary can be useful.
This sort of loophole, using some other existing table to link effects, gets even easier if you add a little Lua in. For instance, in my mod I wanted to create the Empath specialist, a new Specialist type that added +1 Happiness. Obviously, there's no existing stub for tying Happiness to a specialist, and the SetHappiness Lua functions don't actually work, but Buildings CAN add Happiness. So instead I gave the empath a token Food production, and at the end of the turn I loop over all cities, see how many Empaths are present, and add a custom NoLimit building that adds +1 UnmoddedHappiness for each empath. (I could have subtracted off the food at the same time, but +1 Happy and +2 food isn't too overpowered in the later eras.)
It's a little messy, in that it'll only update once per turn, but it works well.

Point is, you can't just do what you'd asked about, copying a table from one file to another. But similar effects CAN be achieved through some creative programming.
 
Thanks a lot, I'll check it up. The Building solved half of the Trait issue:)
What i meant with "The name of the file" was the Lua file where the Vanilla table definitions where located (My trait will be that great engineers spawn at double rate, planned to use the babylonians' "great scientists spawn at double rate" as a template:))
 
What i meant with "The name of the file" was the Lua file where the Vanilla table definitions where located

There is no general vanilla table definition. Each table is fully defined a the top of the file in which it is used, with one single exception: the Leaders files share a common schema file. Technically you could put all of the leaders into a single file with the table at the top, but it was just more readable this way. (The non-GameData XML, such as sound definitions, often follow a similar pattern.)

But for everything else, the definition is right there in the file.
 
Back
Top Bottom