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

Quick Modding Questions Thread

Discussion in 'Mod Creation Help' started by Leyrann, Oct 28, 2018.

  1. Pizza Guy

    Pizza Guy Chieftain

    Joined:
    Jun 29, 2016
    Messages:
    17
    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
     
  2. Sejick

    Sejick Chieftain

    Joined:
    Feb 28, 2018
    Messages:
    12
    Gender:
    Male
    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.
     
  3. Gloompy

    Gloompy Chieftain

    Joined:
    Apr 15, 2019
    Messages:
    52
    I have done it before, and im just a moron and forgot how to do it again. We have different difficulties: https://civ6.gamepedia.com/Game_difficulty <---- there's the chart, and I wanna change the values on those charts. How do I do it? Thanks.
     
  4. Pizza Guy

    Pizza Guy Chieftain

    Joined:
    Jun 29, 2016
    Messages:
    17
    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: Jun 15, 2019
  5. dwwartist

    dwwartist Chieftain

    Joined:
    Mar 21, 2019
    Messages:
    1
    Gender:
    Male
    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
     
  6. Sejick

    Sejick Chieftain

    Joined:
    Feb 28, 2018
    Messages:
    12
    Gender:
    Male
    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: Jun 16, 2019
  7. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,288
    Location:
    Illinois, USA
    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.
     
  8. Wasteland_Wanderer

    Wasteland_Wanderer Chieftain

    Joined:
    Jun 22, 2018
    Messages:
    13
    Gender:
    Male
    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?
     
  9. Pizza Guy

    Pizza Guy Chieftain

    Joined:
    Jun 29, 2016
    Messages:
    17
    Last edited: Jun 19, 2019
  10. V. Soma

    V. Soma long time civ fan

    Joined:
    Apr 13, 2004
    Messages:
    3,823
    Gender:
    Male
    Location:
    Hungary
    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?
     
  11. ShiroToraRyu

    ShiroToraRyu Civ 6 Modder

    Joined:
    Apr 26, 2014
    Messages:
    356
    Gender:
    Male
    Location:
    Planet Earth
    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.
     
  12. Seleuceia

    Seleuceia Chieftain

    Joined:
    Jun 20, 2019
    Messages:
    3
    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.
     
  13. ShiroToraRyu

    ShiroToraRyu Civ 6 Modder

    Joined:
    Apr 26, 2014
    Messages:
    356
    Gender:
    Male
    Location:
    Planet Earth
    you can find the answer in LeeS‘ Modding Guide.

    https://forums.civfanatics.com/threads/lees-civilization-6-modding-guide.644687/
     
  14. Seleuceia

    Seleuceia Chieftain

    Joined:
    Jun 20, 2019
    Messages:
    3
    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.
     
  15. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,288
    Location:
    Illinois, USA
    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).
     
  16. Seleuceia

    Seleuceia Chieftain

    Joined:
    Jun 20, 2019
    Messages:
    3
    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.
     
  17. Pizza Guy

    Pizza Guy Chieftain

    Joined:
    Jun 29, 2016
    Messages:
    17
    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.
     
  18. Zur13

    Zur13 Chieftain

    Joined:
    Nov 7, 2018
    Messages:
    25
    Gender:
    Male
    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.
     
  19. Lonecat Nekophrodite

    Lonecat Nekophrodite Prince

    Joined:
    Jan 10, 2019
    Messages:
    370
    Gender:
    Male
    How can I modify existing units (For example, Bombard, from Late Renaissance Era to Late Medieval) so to make rooms for a custom made ones? Do I have to make a new files to do so? (Vanilla)
     
  20. LeeS

    LeeS Imperator

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

Share This Page