Quick Modding Questions Thread

Are there any good sources to start learning "lua"? I want to make a new unit that I can't just use xml or sql for

LeeS has a good introductory guide to LUA if you are relatively new to coding in general. There is also a lengthy list of LUA functions and objects by Gedemon (note that it is not 100% complete). The best way to learn is probably to look at existing mods or scenarios that have similar effects to what you are looking for and see how the LUA was implemented. The Australia Scenario, for example, has an associated script that does some things like create units and cities, grant players gold, and reveal parts of the map.
 
Can someone explain to me why this doesn't work?

Code:
--------------------------------------------------------------
-- Types (Modifiers) --
--------------------------------------------------------------
insert into Types
            (Type,                                                        Kind            )
    values    ('PIZ_CIVILIZATION_TEST_UA_MODTYPE_FREE_TECH',            'KIND_MODIFIER'    ),
            ('PIZ_CIVILIZATION_TEST_UA_MODTYPE_BONUS_TRADE_ROUTE',    'KIND_MODIFIER'    ),
            ('PIZ_CIVILIZATION_TEST_UA_MODTYPE_TILE_BONUS_DOM_GOLD',    'KIND_MODIFIER'    ),
            ('PIZ_CIVILIZATION_TEST_UA_MODTYPE_TILE_BONUS_FOOD',        'KIND_MODIFIER'    );
--------------------------------------------------------------
-- Modifiers --
--------------------------------------------------------------
insert into Modifiers
            (ModifierId,                                                    ModifierType)
    values    ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_FREE_TECH',                'PIZ_CIVILIZATION_TEST_UA_MODTYPE_FREE_TECH'),
            ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_BONUS_TRADE_ROUTE',        'PIZ_CIVILIZATION_TEST_UA_MODTYPE_BONUS_TRADE_ROUTE'),
            ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_TILE_BONUS_DOM_GOLD',        'PIZ_CIVILIZATION_TEST_UA_MODTYPE_TILE_BONUS_DOM_GOLD'),
            ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_TILE_BONUS_FOOD',            'PIZ_CIVILIZATION_TEST_UA_MODTYPE_TILE_BONUS_FOOD');
--------------------------------------------------------------
-- TraitModifiers --
--------------------------------------------------------------
insert into TraitModifiers
            (TraitType,                                ModifierId                                        )
    values    ('PIZ_CIVILIZATION_TEST_UA_TRAIT',    'PIZ_CIVILIZATION_TEST_UA_MODIFIER_FREE_TECH'),
            ('PIZ_CIVILIZATION_TEST_UA_TRAIT',    'PIZ_CIVILIZATION_TEST_UA_MODIFIER_BONUS_TRADE_ROUTE'),
            ('PIZ_CIVILIZATION_TEST_UA_TRAIT',    'PIZ_CIVILIZATION_TEST_UA_MODIFIER_TILE_BONUS_DOM_GOLD'),
            ('PIZ_CIVILIZATION_TEST_UA_TRAIT',    'PIZ_CIVILIZATION_TEST_UA_MODIFIER_TILE_BONUS_FOOD');
--------------------------------------------------------------
-- DynamicModifiers --
--------------------------------------------------------------
insert into    DynamicModifiers
            (ModifierType,                                                CollectionType,        EffectType                                    )
    values    ('PIZ_CIVILIZATION_TEST_UA_MODTYPE_FREE_TECH',            'COLLECTION_OWNER',    'EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY'    ),
            ('PIZ_CIVILIZATION_TEST_UA_MODTYPE_BONUS_TRADE_ROUTE',    'COLLECTION_OWNER',    'EFFECT_ADJUST_TRADE_ROUTE_CAPACITY'        ),
            ('PIZ_CIVILIZATION_TEST_UA_MODTYPE_TILE_BONUS_DOM_GOLD',    'COLLECTION_OWNER',    'EFFECT_ADJUST_CITY_TRADE_ROUTE_YIELD_FOR_DOMESTIC'),
            ('PIZ_CIVILIZATION_TEST_UA_MODTYPE_TILE_BONUS_FOOD',        'COLLECTION_OWNER',    'EFFECT_ADJUST_CITY_TRADE_ROUTE_YIELD_PER_LOCAL_BONUS_RESOURCE_FOR_INTERNATIONAL');
--------------------------------------------------------------
-- ModifierArguments --
--------------------------------------------------------------
insert into ModifierArguments
            (ModifierId,                                                    Name,            Type,                Value                    )
    values    ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_FREE_TECH',                'TechType',        'ARGTYPE_IDENTITY',    'TECH_ANIMAL_HUSBANDRY'    ),
            ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_TILE_BONUS_DOM_GOLD',        'Amount',        'ARGTYPE_IDENTITY',    2                        ),
            ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_TILE_BONUS_DOM_GOLD',        'YieldType',    'ARGTYPE_IDENTITY',    'YIELD_GOLD'            ),
            ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_TILE_BONUS_FOOD',            'Amount',        'ARGTYPE_IDENTITY',    1                        ),
            ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_TILE_BONUS_FOOD',            'YieldType',    'ARGTYPE_IDENTITY',    'YIELD_FOOD'            ),
            ('PIZ_CIVILIZATION_TEST_UA_MODIFIER_BONUS_TRADE_ROUTE',        'Amount',        'ARGTYPE_IDENTITY',    1                        );

What it is supposed to do is give a free technology and trade route. Which it does. But it's also supposed to provide bonus gold for domestic trade routes, and bonus food for international trade routes depending on the origin cities bonus resources. These parts do not work. As far as I can tell, nothing is wrong with the code. Nothing appears in any of the logs. They just don't work. I'm even using the same EffectType from Persia's power, but it still does not work.

Edit: I changed collecton type from 'COLLECTION_OWNER' to 'COLLECTION_PLAYER_CITIES' and it seems to work
 
Last edited:
Unit help? Is there a way to prevent or eliminate a unit from ever being built in the game? Such as the "Pike and Shot"? Any suggestions would be greatly appreciated. Thanks
 
Unit help? Is there a way to prevent or eliminate a unit from ever being built in the game? Such as the "Pike and Shot"? Any suggestions would be greatly appreciated. Thanks

I think the safest way would be to create a dummy Trait and not assign it to any civilizations or leaders, and then set the TraitType for the units you want to exclude as the dummy trait. Sort of like how UNIT_BARBARIAN_HORSE_ARCHER is assigned TRAIT_BARBARIAN.

Edit: You may also need to update UnitUpgrades so that UNIT_PIKEMAN upgrades directly to UNIT_AT_CREW, for example. And, if you want unique unit replacements to remain, remove any entries of your eliminated units from UnitReplaces.
 
Last edited:
And, of course, as soon as I said this, I tried one more thing and it worked. I got rid of the GameData block and put everything into GameInfo, like this

Code:
<GameInfo>
    <GlobalParameters>

        <Replace Name="COMBAT_ARMY_STRENGTH_MODIFIER" Value="42" />

        <Replace Name="COMBAT_CORPS_STRENGTH_MODIFIER" Value="25" />

    </GlobalParameters>
    <Units>
        <Update>
            <Where UnitType="UNIT_WARRIOR"/>
            <Set BaseMoves="25"/>
        </Update>
    </Units>
</GameInfo>

and everything suddenly magically worked, although I could swear that I did exactly the same thing like a week ago, and it didn't take. I don't know, I'm just a stupid programmer.

David
Yes, your problem was having two different "root-level" syntax commands within the same file. The game will implement either <GameInfo> -- </GameInfo> or <GameData> -- </GameData>, but not both within the same file. If both are used as you were doing, the lower of the two root-level segements is ignored.

If the following is done, however, the game will reject everything because of a fatal syntax error
Code:
<GameInfo>
     <GameData>
          ---stuff---
     </GameData>
</GameInfo>
It does not matter in this second example whether GameInfo is the "outer" or root level or whether GameData is used as the outer level: the syntax will be rejected in either case.
 
Hi. I'm really new to creating mods and unsure how to actually start what I want to do. I want to make small mod for Civ 6 that edits Tamar's leader ability to also give +2 diplomatic points per turn for each foreign capital that has a Tamar's religion as its majority. I can't find any video or such that explains how to edit existing leaders, could someone point me in the right direction? Also is the new ability I want to add something that can be added into the game at the moment?
 
Well, I have a mod that worked fine, but now after the "June Soon" patch it is not working - just what should I do to adjust it to the game now...? Is there a general bit of code to add as related to the patch?
 
Well, I have a mod that worked fine, but now after the "June Soon" patch it is not working - just what should I do to adjust it to the game now...? Is there a general bit of code to add as related to the patch?

i will not be of a big help unfortunately....at least i can tell you that the „general bit of code to add“ - is probably not what you have to do, cause my wip-unreleased-mod works great, just as before the patch.
maybe you should watch the forum, most of the times when a patch happens, soon the modders will start a related thread at the CFC forum, something like „changes to modding as of ..... Patch/Expansion/DLC.
 
How does one edit an existing table definition in an .xml file? There are some existing table definitions where the references have typos and I want to fix them. For example, the table definition may refer to "Stage" for the reference but the table is called "Stages". Or, the reference is referred to as a Atlas but really is a Type. I'm trying to make this work with another mod that isn't mine, so I can't edit the original table definition directly, I need to modify it with a delete or update or something.

I'm using ModBuddy and .xml if that makes any difference. I've tried simply copying and pasting the whole table definition (with the changes I want) into an .xml, but that doesn't do anything (not that I expected it to). I've also put <Delete/> at the top of those copy/pastes to sort of "rewrite" it, but that isn't working either. Any help would be appreciated.
 
How does one edit an existing table definition in an .xml file? There are some existing table definitions where the references have typos and I want to fix them. For example, the table definition may refer to "Stage" for the reference but the table is called "Stages". Or, the reference is referred to as a Atlas but really is a Type. I'm trying to make this work with another mod that isn't mine, so I can't edit the original table definition directly, I need to modify it with a delete or update or something.

I'm using ModBuddy and .xml if that makes any difference. I've tried simply copying and pasting the whole table definition (with the changes I want) into an .xml, but that doesn't do anything (not that I expected it to). I've also put <Delete/> at the top of those copy/pastes to sort of "rewrite" it, but that isn't working either. Any help would be appreciated.

you can find the answer in LeeS‘ Modding Guide.

https://forums.civfanatics.com/threads/lees-civilization-6-modding-guide.644687/
 
Thank you for the response, though I am not sure that guide (or any I've found) address what I want. Just to be clear, I need to edit a Table Defintion, not a Table. Let me give an example. Let's say there is an existing table definition like this:

<Table name="Stage">
<Column name="Type" type="text" notnull="true" unique="true"/>
<Column name="PrimaryColor" type="text" default="NULL" reference="Colors(Atlas)"/>
</Table>

I need to do 2 things:
1) Change the name of the table from "Stage" to "Stages"
2) Change the reference in the second line from "Colors(Atlas)" to "Colors(Type)"

Unfortunately, I can't simply fix the typos in the original file (it's complicated but in short I'm trying to avoid a bunch of work and probable breaking of things). Is there a way to edit the table definition, say similar to how you can update or delete and rewrite rows in table? Everything I have found (and maybe I'm searching the wrong term) is about following table definitions or modifying just plain tables.
 
  1. You cannot alter a table definition with XML
  2. You cannot alter the name of a table once the table-name has been defined either in XML or SQL
  3. Effectively, you can only alter an existing table with SQL in order to add a new column to the table
There should never be a need to change the name of a game-table, even if it were called "Quatloos" so long as all other tables referring to it are also using the name "Quatloos". And if other tables are referring to it as something other than "Quatloos", then the problem lies in the definitions of the other tables and their incorrect references.

It is unclear whether you are talking about a Firaxis-defined table or a table added by a mod but I am assuming you are referring to a table created by a mod. You should never attempt to alter the definition of a Firaxis-created game-table other than to add a new column to it (which is pretty much all you can do anyway).
 
Thank you for the help. Not what I was hoping for, but also not surprising. I'm guessing then this also means you can't edit a column to change (or add) a default value if the column already exists, which would have saved me some time...oh well.
 
So are there any good tutorials for adding art to mods? Like leader art, icons, and the such. I've tried looking at a few but it's really confusing.
 
Anyone knows the simple way to track unit modifier changes? I need to do some actions in my mod when the unit receives new modifier or lose existing one.
 
You make an Update to the Definition of the Unit, re-assigning its PrereqTech or PrereqCivic, and its ObsoleteTech, ObsoleteCivic, MandatoryObsoleteTech, and MandatoryObsoleteCivic as necessary if the unit has one of the "Obsoletes" or you wish to add one.

If you are making an actual mod it is never necessary to add a complete new file just to make a change to existing data in the database. All you need to do is add the necessary Update (either in SQL or XML) to an existing file of the mod which is being loaded as an InGameAction of type UpdateDatabase.
 
How do I make a modifier that gives +2 oil for every oil resource? I tried to find out by following england's trait but I can't find out anymore past what their trait is called in game
 
Top Bottom