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

How do I mod default values for 'create game'?

Discussion in 'Civ6 - Creation & Customization' started by Finwickle, Nov 8, 2016.

  1. Finwickle

    Finwickle Chieftain

    Joined:
    Oct 29, 2016
    Messages:
    13
    I tried to make a very simple mod to change the default values for Create Game. The defaults are standard speed and small map, and I always play a large map on epic speed. So I constructed a simple mod to change those, but it doesn't work. See mod code below. If I include code to delete Egypt as a civ, that does work (Cleo disappeared from the list). So the mod is loaded and does activate, just not for the DefaultValues.

    What am I doing wrong?

    Spoiler mod code (FinwicklesTuningMod_Config.xml) :
    Code includes both the Update and Replace command to see if either works, but they both won't.

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <GameInfo>
    
       <!-- Adjust default starting parameters: game difficulty, game speed, map size -->
       <!-- origin: Base\Assets\Configuration\Data\SetupParameters.xml -->
       <Parameters>
           <!-- Game Options -->
            <Update>
                <Where ParameterId="GameDifficulty" />
                <Set DefaultValue="DIFFICULTY_WARLORD" />
            </Update>
           <Replace ParameterId="MapSize" Name="LOC_MAP_SIZE" Description="" Domain="StandardMapSizes" DefaultValue="MAPSIZE_LARGE" ConfigurationGroup="Map" ConfigurationId="MAP_SIZE" Hash="1" GroupId="MapOptions" SortIndex="220"/>
            <Update>
               <!-- Sets only single player default game speed -->
                <Where ParameterId="GameSpeeds" SupportsLANMultiplayer="0" />
                <Set DefaultValue="GAMESPEED_EPIC" />
            </Update>
       </Parameters>
      
    </GameInfo>
    

    Spoiler modinfo file :
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <Mod id="62F89EF8-4F75-C609-F6BB-41D81D4BA6A7" version="1">
        <Properties>
            <Name>Finwickle's Tuning Mod</Name>
            <Teaser>Some tuning adjustments</Teaser>
            <Description>Makes several adjustments to the game</Description>
            <Authors>Finwickle</Authors>
           <SpecialThanks>Gedemon for modinfo guide</SpecialThanks>
            <ShowInBrowser>Show</ShowInBrowser>
            <EnabledByDefault>1</EnabledByDefault>
            <EnabledAtStartup>1</EnabledAtStartup>
        </Properties>
       <Dependencies />
       <References />
    
       <Settings>
           <Custom id="FINWICKLE_TUNINGMOD_SETTINGS">
               <Items>
                   <File>FinwicklesTuningMod_Config.xml</File>
               </Items>
           </Custom>
       </Settings>
      
        <Components>
            <UpdateDatabase id="FINWICKLE_TUNINGMOD_UPDATE">
                <Items>
                    <File>FinwicklesTuningMod.xml</File>          
                </Items>
            </UpdateDatabase>
        </Components>
      
        <Files>
           <File>FinwicklesTuningMod_Config.xml</File>          
            <File>FinwicklesTuningMod.xml</File>          
        </Files>
    </Mod>
    
     
  2. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,165
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    <Replace> does the equivalent of a SQL "INSERT OR REPLACE" command. Looking at the constraints (or rather, the lack thereof) of that table, you'll have just added an additional row. You'll want all <Update>'s
     
  3. Rob (R8XFT)

    Rob (R8XFT) Ancient Briton Super Moderator

    Joined:
    Aug 11, 2002
    Messages:
    10,817
    Location:
    Leeds (UK)
  4. skodkim

    skodkim Deity

    Joined:
    Jan 16, 2004
    Messages:
    2,221
    Location:
    Denmark
    Hmm

    I too tried updating the parameters by sql, but Modding.log show the errror message "Error Loading SQL" .

    It all seamed rather simple though. Just tried to update four parameters using an sql with the following lines:

    UPDATE Parameters SET DefaultValue = 'MAPSIZE_HUGE' WHERE ParameterId = 'MapSize'; --MAPSIZE_SMALL
    UPDATE Parameters SET DefaultValue = 1 WHERE (Key2 = 'Continents.lua' AND Name = 'LOC_MAP_SEA_LEVEL_NAME'); -- 2
    UPDATE Parameters SET DefaultValue = 3 WHERE (Key2 = 'Continents.lua' AND Name = 'LOC_MAP_RESOURCES_NAME'); -- 2
    UPDATE Parameters SET DefaultValue = 3 WHERE (Key2 = 'Continents.lua' AND Name = 'LOC_MAP_START_POSITION_NAME'); -- 2

    Any help would be much appreciated :)

    \Skodkim
     
  5. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,165
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    I haven't played around with it much myself, but I believe the issue is that the Parameters table is in the Settings database, not the Components (Game Rules) database.

    See, e.g.:
    @skodkim :
    I don't know how you can use SQL to affect the Settings database. Maybe something like:
    Code:
    UPDATE Settings.Parameters SET...
    ???
     
  6. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    8,766
    Location:
    France
  7. skodkim

    skodkim Deity

    Joined:
    Jan 16, 2004
    Messages:
    2,221
    Location:
    Denmark
    Great help! I'll try using your tips the next time I stay a new game :king:

    \Skodkim
     
  8. Finwickle

    Finwickle Chieftain

    Joined:
    Oct 29, 2016
    Messages:
    13
    I've tried it at first with all <update>'s. When that didn't work I tried <replace>. But it doesn't seem to work for the DefaultValue's.
    My Modding.log doesn't give me any errors. Somewhere in there it states the following:
    [1165622.330] Status: Creating database save point.
    [1165622.330] Status: ModdingUpdateConfigurationDatabase - Loading FinwicklesTuningMod_Config.xml
    [1165622.330] Status: Successfully released save point.
    [1165622.330] Status: Modding Framework - Finished Apply Settings
    [1165622.539] Status: Successfully reconfigured game.

    The default values are still not changed though. Am I maybe looking at the wrong values?
    I did that (or at least, I think I did). I've included the modinfo file in my original post.
     
  9. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,165
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
  10. Finwickle

    Finwickle Chieftain

    Joined:
    Oct 29, 2016
    Messages:
    13
    I might be just blind, but as far as I know I did that. I've used Gedemon's modinfo-structure post to build my modinfo file (included in 1st post), and I have two xml files, one for the <Settings> section (included in 1st post) that changes the <Parameters> values and another for the <Components> section (not included in 1st post) that changes some other settings for gameplay. I just don't see what is wrong with my modinfo-file.
    Edit: but if there is, I'd love to know what :)
     
    Last edited: Nov 10, 2016
  11. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,165
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    That's true, sorry. :blush:

    Hmm... Did you check the database in a SQLite Browser to see if it worked on the proper rows? I wonder if that info is cached by the time the mod goes into effect (therefore requiring you update the base game files instead of using a mod?)
     
  12. Finwickle

    Finwickle Chieftain

    Joined:
    Oct 29, 2016
    Messages:
    13
    I've thought about changing the base game files (which I did for edge scrolling anyway), but don't like to have to do that again with every update for different settings in different files.

    I've tried to stay away from viewing the SQLite database. All I wanted to do was a very simple mod :king:
    But I might get that browser and search for it, when I get some time again. Thanks for the tip.
     
  13. Finwickle

    Finwickle Chieftain

    Joined:
    Oct 29, 2016
    Messages:
    13
    Ok, I might not be blind, but stupid somewhat. I've edited the games files directly, after the last post by @Nutty. And it didn't work either....
    Then I stumbled upon this post, buried on page 8 or something:
    These DefaultValues are the values you get when you press the little "Restore Defaults" button on the Advanced Setup page, not the values you get when you choose "Create Game" from the menu.

    So my mod works fine, it just mods something different than I thought. Thanks for all the replies.
     
  14. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,165
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
  15. Finwickle

    Finwickle Chieftain

    Joined:
    Oct 29, 2016
    Messages:
    13
    I hunted some more and found a (slightly messy) way to still have my own defaults for game creation without the need to press the Reset Defaults button. I've edited the file "C:\Games\SteamGames\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\UI\FrontEnd\AdvancedSetup.lua" and changed the OnShow() function:
    Code:
    function OnShow()
        BuildGameSetup();
        RefreshPlayerSlots();
        GameSetup_RefreshParameters();
            -- added by Finwickle:
            g_GameParameters:ResetDefaults();
        AutoSizeGridButton(Controls.DefaultButton,50,22,10,"H");
        AutoSizeGridButton(Controls.CloseButton,133,36,10,"H");
    end
    Now when I press Create Game, I have my desired difficulty, map size and game speed (set by my mod). It will have to do and will work until a next patch overwrites it, I guess. I have no clue how to mod existing LUA-scripts.

    EDIT: Oops, seems I broke something as well. If you exit to main menu and create another game, it's identical to the previous one. The random seed isn't regenerated, it seems. Needs more experimenting, or someone with some clue about lua. :)
     
    Last edited: Nov 10, 2016
  16. Finwickle

    Finwickle Chieftain

    Joined:
    Oct 29, 2016
    Messages:
    13
    This seems to do the trick:
    Code:
    function OnShow()
        BuildGameSetup();
        RefreshPlayerSlots();
        GameSetup_RefreshParameters();
            -- added by Finwickle:
            OnDefaultButton();
        AutoSizeGridButton(Controls.DefaultButton,50,22,10,"H");
        AutoSizeGridButton(Controls.CloseButton,133,36,10,"H");
    end
     
  17. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,518
    Location:
    Illinois, USA
    For existing game UI lua/xml files, you take a copy of the original file, then edit it. You then add this edited file to your mod and set it as a file to be imported into the game as part of your mod, as in like this as JFD does in his mod:
    Code:
    	<Components>
    		<ImportFiles id="JFD_RULE_WITH_FAITH_IMPORT">
    			<Items>
    				<File>Lua/UI/Overrides/CivicsTree.lua</File>
    				<File>Lua/UI/Overrides/CivicsTree.xml</File>
    				<File>Lua/UI/Overrides/GovernmentScreen.lua</File>
    				<File>Lua/UI/Overrides/GovernmentScreen.xml</File>
    			</Items>
    		</ImportFiles>
    	</Components>
    The game then uses these updated versions of the files instead of the standard ones the game comes with, so long as the mod is activated in the mods menu.

    The actual file names are what are important, and they must match to the existing filename the game uses for X part of the UI. The folder structure within your mod is not important, only the file name of the lua and/or xml file you are importing into the game's Virtual File System.

    The xml files in these cases are all <Context ......> files that tell the game how to build the various UI panels, and therefore can be imported.
     
  18. Finwickle

    Finwickle Chieftain

    Joined:
    Oct 29, 2016
    Messages:
    13
    Thanks for the info. It helped me get some modding going.
     

Share This Page