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

Finwickle

Living in the Layers
Joined
Oct 29, 2016
Messages
314
Location
Europe
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>
 
<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
 
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
 
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.:
There is 2 database [now], there are tags in the modinfo file () to explicitly update one or the other (because for example there is a "Map" table in both, but with a very different content)

For example, from one of the scenario modinfo:
HTML:
    <Components>
        <UpdateDatabase id="COLDWAR_COMPONENT">
            <Properties>
                <RuleSet>RULESET_SCENARIO_COLDWAR</RuleSet>
            </Properties>
            <Items>
                <File>ColdWarScenario_Victories.xml</File>
                <File>ColdWarScenario_Projects.xml</File>
                <File>ColdWarScenario_Units.xml</File>
                <File>ColdWarScenario_WMDs.xml</File>
                <File>ColdWarScenario_Eras.xml</File>
                <File>ColdWarScenario_GlobalParameters.xml</File>
                <File>ColdWarScenario_Policies.xml</File>
                <File>ColdWarScenario_Features.xml</File>
            </Items>
        </UpdateDatabase>
        <GameplayScripts id="COLDWAR_SCRIPT_COMPONENT">
            <Properties>
                <RuleSet>RULESET_SCENARIO_COLDWAR</RuleSet>
            </Properties>
            <Items>
                <File>ColdWarScenario_StartScript.lua</File>
            </Items>
        </GameplayScripts>
    </Components>
    <Settings>
        <Custom id="COLDWAR_SETTING">
            <Items>
                <File>ColdWarScenario_Config.xml</File>
            </Items>
        </Custom>
    </Settings>

the files listed in <UpdateDatabase> under <Components> will update the gameplay database, the file in <Custom> under <Settings> will update the configuration database

note the addition of a <GameplayScripts> tag that is working as intended, but it's another subject.

@skodkim :
I don't know how you can use SQL to affect the Settings database. Maybe something like:
Code:
UPDATE Settings.Parameters SET...
???
 
<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
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.
I too tried updating the parameters by sql, but Modding.log show the errror message "Error Loading SQL" .
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?
The SQL file must be loaded under the <Settings> section of the .modinfo file

edit: http://forums.civfanatics.com/threads/modinfo-structure.600766/
I did that (or at least, I think I did). I've included the modinfo file in my original post.
 
@Finwickle: The above post was directed at both of you. You need to direct the .modinfo to update a different database, as in the quoted post.
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:
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?)
 
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.
 
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:
SetupParameters.xml and MapSizes.xml at Assets/Configuration/

but only works after pressing default button.. plz tell me if you setup without default button
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.
 
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:
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
 
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.
 
Back
Top Bottom