[Vanilla] How does the Replace tag work on earth?

gqqnbig

Chieftain
Joined
Apr 15, 2020
Messages
26
I hear if I need to change text or provide localized text, I use

<GameData>
<LocalizedText>
<!-- The name of the building. -->
<Replace Tag="LOC_BUILDING_LOCAL_FACTORY_NAME" Language="en_US">
<Text>Local Factory</Text>
</Row>


Say if I want to replace
<Boosts>
<!-- Some boosts, like find natural wonder, have an unnecessary unit field - that is an aid for the AI. Please leave it -->
<Row TechnologyType="TECH_SAILING" Boost="50" TriggerDescription="LOC_BOOST_TRIGGER_SAILING" TriggerLongDescription="LOC_BOOST_TRIGGER_LONGDESC_SAILING" BoostClass="BOOST_TRIGGER_SETTLE_COAST"/>

TECH_SAILING boost from 50 to 90, how do I write the replace tag?

Basically, what is the syntax for the tags? What attributes are available? What is the documentation I should read?
 
Besides, what is the recommanded way of replacing things? I'm a senior software developer, but new to CIV modding. Should I use SQL or stick to XML?
 
I'm not the greatest modder around but if you know sql then xml is likely strictly inferior for you: it is mostly translated 1:1 to sql and is not as flexible sql. I believe xml is superior for some people as being easier to read but functionally it is now as powerful.
 
SQL is more efficient IMO to change values in existing rows, civ6 use SQLite for which you'll find tutorials all over the web, while XML tags are civ specific AFAIK.

You'll also found the tables schema in the game's folder (01_GameplaySchema.sql)
 
<Replace> is exactly equivalent to SQL's INSERT OR REPLACE INTO
Code:
<Boosts>
     <!-- Some boosts, like find natural wonder, have an unnecessary unit field - that is an aid for the AI. Please leave it -->
     <Replace TechnologyType="TECH_SAILING" Boost="90" TriggerDescription="LOC_BOOST_TRIGGER_SAILING" TriggerLongDescription="LOC_BOOST_TRIGGER_LONGDESC_SAILING" BoostClass="BOOST_TRIGGER_SETTLE_COAST"/>
</Boosts>
Will have the same effects as
Code:
<Boosts>
     <Update>
          <Where TechnologyType="TECH_SAILING" />
          <Set Boost="90" />
    </Update>
</Boosts>
Except that using <Replace> syntax will re-order the rows in the table in most cases whereas <Update> will not. This can cause issues where the game expects the rows in a specific table to be in a specific order. Also when using <Replace> you need to ensure you are carrying-over all the information from the original row definition that the game will need to operate correctly. Forgetting to include the designation for the "TriggerDescription" for example would cause the game's User Interface system to not properly display the needed text for the boost pop-up.

An Update command only alters the data for the columns specified and leaves the rest of the row intact.

As @Gedemon said the Schema definitions are located in file
C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization VI\Base\Assets\Gameplay\Data\Schema/01_GameplaySchema.sql
Every game table has a specific set of columns that can be used, and a specific set or requirements for the type of information a given column can contain.

Additionally, the two expansions add new game-tables to the Schema:
  • Definitions of expac1 (RaF) gametables are at C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\DLC\Expansion1\Data/Expansion1_Schema.sql
  • Definitions of expac2 (GS) gametables are at C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\DLC\Expansion2\Data/Expansion2_Schema.sql
 
Top Bottom