Going beyond XML

Gushis

Chieftain
Joined
Feb 6, 2017
Messages
50
So I've been making mods for a while but I've only really used XML. Now I'm wondering how to really make new mechanics, for example +1 faith from every tile that makes at least +1 gold during golden age. Or a building making a resource tile its built. I don't know if it's LUA or SQL or what...
 
The kinds of effects you're looking for will largely be done through Lua.

Your most useful reference will probably be whoward's spreadsheet of all Lua methods (can be downloaded from this thread); it's also helpful to find other existing mods that do similar things to what you want to achieve, which you can then adapt as needed. (Of course, if you do this second thing, make sure to credit the people whose code you're borrowing!)
 
SQL won't allow you to create dynamic and changing in-game effects. As @TopHatPaladin said, lua is required for this.

SQL is where XML code actually goes -- they both add or alter things in the game's database. XML is translated into SQL and then inserted into the game's database. Once the game is started, the database is locked. So if the database says a building gives +1 Faith, nothing can be done by database methods to make it give dynamicaly more than or less than that +1 Faith depending on in-game conditions like a golden age being active. We have to turn to lua for that sort of effect.

Directly effecting a plot's yields via lua is possible but has many issues associated with it. If your lua code does not track whether or not that plot has already been adjusted, you get compound effects on the same tile, for example. And then you need to use a data-saving method to store the information about which tiles have been adjusted so that when a user saves and then later reloads that saved game, the lua code does not compound an effect on a tile that has already been adjusted.

One method mod-maker's often use to get around these these data-tracking and data-saving issues is to use dummy buildings, each of which for example gives +1 Faith. Then we just count via lua the number of tiles that qualify for the + Faith effect, and add that number of dummy buildings to a city. The game allows us to add more than one copy of the same building to a city in Civ5, and lua can later on access and count how many of a given building have been added to a city. Lua can then also take away all these dummy buildings as conditions require.
 
Or a building making a resource tile its built.

Or using/making custom DLL mods ( C++ ). for example this exists in the CP already, only need to use XML/SQL to make use of it. Many new kind of effects like you describe are in custom DLLs already, but maybe not the exact things youre looking for.
 
Back
Top Bottom