Simple Modular XML edits?

rian222

Chieftain
Joined
Jul 31, 2013
Messages
39
Location
Japan
Does anyone know how to make a simple XML edit included itself in a downloadable mod? I feel like this is probably super simple. Within Leaders_Text.xml in the game folder I find the line:


Code:
<Row Tag="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION">
            <Text>All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 50 hit points.</Text>
        </Row>

What I want to do is change the description on Tomyris's Killer of Cyrus ability in-game to say that they heal up to 25 hit points. I have already made the changes to them within the game using SQL, but the description still says '50'. It's insanely easy to do on my own computer, all I have to do is change that number to 25 instead of 50 and save it. The solution I have tried that doesn't work is changing the .modinfo file to read:

Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="a8634fd4-62e4-4789-bbff-e094b46603c1" version="1">
    <Properties>
        <Name>Balanced Units</Name>
        <Teaser>Balances cavalry, anti-cavalry, and air units.</Teaser>
        <Description>Lowers the combat strength of all cavalry and anti-cavalry units while raising production costs.  Raises combat strength of air units, decreases production costs, and raises air slots in Aerodrome district and carriers.  Various adjustments to some unique units.</Description>
        <Authors>Cerkoryn</Authors>
    </Properties>

    <!-- Files included -->
    <Files>
        <File>BalancedUnitsCode.sql</File>
        <File>BalancedUnitsText.xml</File>
    </Files>

    <!-- Different parts of the mod -->
    <Components>
        <UpdateDatabase id="UnitBalanceChanges">
            <Items>
                <File>BalancedUnitsCode.sql</File>
                <File>BalancedUnitsText.xml</File>
            </Items>
        </UpdateDatabase>
    </Components>
</Mod>

The .sql file makes the changes that work fine. The .xml file I made says this:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- edited by Cerkoryn as part of the Balanced Units mod. -->
<GameData>
    <BaseGameText>
        <Row>
            <Update>
                <Where Tag="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION"/>
                <Set Text="All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points."/>
            </Update>
        </Row>
    </BaseGameText>
</GameData>

But it still says 50 in game. What am I doing wrong?
 
Texts are not stored in the same database, you have to use a <LocalizedText> section under components in the modinfo
Code:
   <LocalizedText id="UnitBalanceChangesTexts">
      <Items>
        <File>BalancedUnitsText.xml</File>
      </Items>
    </LocalizedText>
 
Still doesn't work. .modinfo file now reads:

Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="a8634fd4-62e4-4789-bbff-e094b46603c1" version="1">
    <Properties>
        <Name>Balanced Units</Name>
        <Teaser>Balances cavalry, anti-cavalry, and air units.</Teaser>
        <Description>Lowers the combat strength of all cavalry and anti-cavalry units while raising production costs.  Raises combat strength of air units, decreases production costs, and raises air slots in Aerodrome district and carriers.  Various adjustments to some unique units.</Description>
        <Authors>Cerkoryn</Authors>
    </Properties>

    <!-- Files included -->
    <Files>
        <File>BalancedUnitsCode.sql</File>
        <File>BalancedUnitsText.xml</File>
    </Files>

    <!-- Different parts of the mod -->
    <Components>
        <UpdateDatabase id="UnitBalanceChanges">
            <Items>
                <File>BalancedUnitsCode.sql</File>
            </Items>
        </UpdateDatabase>
        <LocalizedText id="UnitBalanceChangesTexts">
            <Items>
                <File>BalancedUnitsText.xml</File>
            </Items>
        </LocalizedText>
    </Components>
</Mod>

Tried changing a couple other things around too after applying your changes. Still no dice :(
 
You don't want those <Row> tags around your <Update> tag. Row is used for creating a new entry, Update is used instead of Row to change an existing entry.

e.g.
Code:
<GameData>
    <BaseGameText>
            <Update>
                <Where Tag="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION"/>
                <Set Text="All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points."/>
            </Update>
    </BaseGameText>
</GameData>
 
Didn't know that, thanks. I wish I could just find the table in SQLite, I am much more comfortable with that than XML editing. Tried removing the <Row> tags though and still didn't work. Anything else?
 
I've been messing around with this all day and still can't figure out what I'm doing wrong. Anybody have any idea?
 
SQLite Manager for Firefox, lets you browse the database (not localized text though since we dont have access to that atm). An you can do your edits via SQL.
Check your database.log and modding.log files, located in My Games/Civ 6/logs
 
SQLite Manager for Firefox, lets you browse the database (not localized text though since we dont have access to that atm). An you can do your edits via SQL.
Check your database.log and modding.log files, located in My Games/Civ 6/logs

Wait, so I can do an SQL update that says:

Code:
UPDATE LocalizedText SET Text=
"All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points." WHERE Tag=
"LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION"

I'll try that as soon as I get home, I'm on my phone right now. I had no idea that database even existed since I can't see it in SQLite.
 
Dont use double quotes. Single Quotes for strings.

'Single Quotes'

Check My Games/Civ 6/Cache

You will find the database files.
 
Localization table is hotloaded (I think) when you boot the game, you can make edits to it via SQL (I do so in most my mods) but you can NOT add new entries via SQL.
 
You cannot use <BaseGameText> in a mod. You must use <LocalizedText>.

The contents of your xml text file needs to be:
Code:
<GameData>
    <LocalizedText>
            <Update>
                <Where Tag="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION" Language="en_US"/>
                <Set Text="All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points."/>
            </Update>
    </LocalizedText>
</GameData>
But it is actually easier to use Replace syntax as follows:
Code:
<GameData>
    <LocalizedText>
            <Replace Tag="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION" Language="en_US"/>
                <Text>All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points.</Text>
            </Replace>
    </LocalizedText>
</GameData>
 
So after looking at others' work who have done similiar mods and a lot of trial and error, I found something that works. However, I still don't understand why, and I wish I did. This is what works:

.modinfo
Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="a8634fd4-62e4-4789-bbff-e094b46603c1" version="1">
    <Properties>
        <Name>Balanced Units</Name>
        <Teaser>Balances cavalry, anti-cavalry, and air units.</Teaser>
        <Description>Lowers the combat strength of all cavalry and anti-cavalry units while raising production costs.  Raises combat strength of air units, decreases production costs, and raises air slots in Aerodrome district and carriers.  Various adjustments to some unique units.</Description>
        <Authors>Cerkoryn</Authors>
    </Properties>

    <!-- Files included -->
    <Files>
        <File>BalancedUnitsCode.sql</File>
        <File>BalancedUnitsText.xml</File>
    </Files>

    <!-- Different parts of the mod -->
   
    <Settings>
        <LocalizedText id="UnitBalanceChangesTexts">
            <Items>
                <File>BalancedUnitsText.xml</File>
            </Items>
        </LocalizedText>
    </Settings>
       
    <Components>
        <UpdateDatabase id="UnitBalanceChanges">
            <Items>
                <File>BalancedUnitsCode.sql</File>
            </Items>
        </UpdateDatabase>
        <LocalizedText id="UnitBalanceChangesTexts">
            <Items>
                <File>BalancedUnitsText.xml</File>
            </Items>
        </LocalizedText>
    </Components>
   
    <LocalizedText>
        <Text id="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION">
            <en_US>
            All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points.
            </en_US>
        </Text>
    </LocalizedText>

.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- edited by Cerkoryn as part of the Balanced Units mod. -->

<GameData>
    <BaseGameText>
        <Replace Tag="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION">
            <Text>All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points.</Text>
        </Replace>
    </BaseGameText>
</GameData>

However, if I change <BaseGameText> to <LocalizedText> in the .xml file, it no longer works. Also, if I remove everything between the <Settings> tags in the .modinfo, it also no longer works. Lastly, if I remove everything within the <LocalizedText> in the .modinfo file, it doesn't work.

Somehow it appears I need all 3 of these things for it to affect the text in-game. What I am thinking is that LocalizedText is a database made for running changes made in mods while BaseGameText is a database where this actual text is stored. Is that correct? Why is the stuff within <Settings> necessary then?
 
Under settings you put what your mod need to acces on the setup screen (like civilizations/leaders names, icons, etc...)

Under components, what it needs to access in the game.
 
As @Gedemon said, and as in the attached mod.

Note that the attached mod only has the code needed for the display of the desired text. It has nothing for the actual effect on the amount of unit healing.

----------------------------------------------------------------------------------------------------------

This in the modinfo file does not actually accomplish anything:
Code:
    <LocalizedText>
        <Text id="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION">
            <en_US>
            All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points.
            </en_US>
        </Text>
    </LocalizedText>
<LocalizedText> in the modinfo file is only for what to display in the Additional Content Menus and in the list of active mods. You can verify this chunk of code in the modinfo file has no actual effect by leaving this in your modinfo file and changing "25" to "2500". You will not see any change on the leader selection menus nor in-game anywhere reflecting "2500".

----------------------------------------------------------------------------------------------------------

<BaseGameText> actually does work in a mod, but it is not adaptive to other languages. This is why for any mod you may wish to share with others you want to as a general rules use <LocalizedText>. The use of the LocalizedText "table" requires you to specify the language that is being written-to, however. As in this where everything shown is 100% required:
Code:
<GameData>
	<LocalizedText>
		<Replace Tag="LOC_TRAIT_LEADER_KILLER_OF_CYRUS_DESCRIPTION" Language="en_US">
			<Text>All units receive +5 [ICON_Strength] Combat Strength when attacking wounded units. When they eliminate a unit, they heal up to 25 hit points.</Text>
		</Replace>
	</LocalizedText>
</GameData>
----------------------------------------------------------------------------------------------------------

You will note in the attached mod I am loading the same Text file both into the <Settings> text localization and the <Components> text localization.
 

Attachments

Aha! That was it! I was missing

Code:
Language="en_US"

I can't believe I kept missing that, I feel dumb haha. I was also able to delete the extra useless info within <LocalizedText> in the .modinfo. Everything makes so much more sense now!

I do have one more simple question though if you don't mind: Why are the lines within <Settings> necessary for the mod to work? The .xml tells the mod what changes to make and the <Files> and <Components> sections already tell the mod to load the .xml. I don't see why anything more is necessary.
 
I do have one more simple question though if you don't mind: Why are the lines within <Settings> necessary for the mod to work? The .xml tells the mod what changes to make and the <Files> and <Components> sections already tell the mod to load the .xml. I don't see why anything more is necessary.
It normally isn't. Have you tried without?
 
I did, it didn't work. Here's the code without the <Settings> stuff:

Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="a8634fd4-62e4-4789-bbff-e094b46603c1" version="1">
    <Properties>
        <Name>Balanced Units</Name>
        <Teaser>Balances cavalry, anti-cavalry, and air units.</Teaser>
        <Description>Lowers the combat strength of all cavalry and anti-cavalry units while raising production costs.  Raises combat strength of air units, decreases production costs, and raises air slots in Aerodrome district and carriers.  Various adjustments to some unique units.</Description>
        <Authors>Cerkoryn</Authors>
    </Properties>

    <!-- Files included -->
    <Files>
        <File>BalancedUnitsCode.sql</File>
        <File>BalancedUnitsText.xml</File>
    </Files>

    <!-- Different parts of the mod -->
      
    <Components>
        <UpdateDatabase id="UnitBalanceChanges">
            <Items>
                <File>BalancedUnitsCode.sql</File>
            </Items>
        </UpdateDatabase>
      
        <LocalizedText id="UnitBalanceChangesTexts">
            <Items>
                <File>BalancedUnitsText.xml</File>
            </Items>
        </LocalizedText>
    </Components>
  
</Mod>

And here's what I took out:

Code:
<Settings>
        <LocalizedText id="UnitBalanceChangesTexts">
            <Items>
                <File>BalancedUnitsText.xml</File>
            </Items>
        </LocalizedText>
    </Settings>
 
It is because anything in <Components> is not activated until after you click "Start Game" after you select your desired leader, civ, map-type, etc., or "Load Game" to reload a saved game.

<Settigs> is used on the "configuration" of the game, which appears to also apply to Text alterations, and is best thought of as everything that happens up to the point where you click "Start Game" or "Load Game".

@sp00n It actually is required for anything related to Civilizations, Leaders, etc., in order to get these text changes to display in the game setp-up menus and saved game loading menus.
 
Last edited:
Aha, that makes sense! I was checking the text at the leader screen, before starting the game. This is exactly how I want it to be, all my questions are answered. Thanks a ton guys!
 
Back
Top Bottom