1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Going beyond XML

Discussion in 'Civ5 - Creation & Customization' started by Gushis, Sep 22, 2018.

  1. Gushis

    Gushis Chieftain

    Joined:
    Feb 6, 2017
    Messages:
    50
    Gender:
    Male
    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...
     
  2. TopHatPaladin

    TopHatPaladin Warlord

    Joined:
    Nov 5, 2017
    Messages:
    116
    Gender:
    Male
    Location:
    New England
    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!)
     
  3. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,637
    Location:
    Illinois, USA
    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.
     
  4. Deadstarre

    Deadstarre Expert

    Joined:
    Nov 1, 2015
    Messages:
    960
    Location:
    New York
    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.
     

Share This Page