Need help getting my two .sql files working

Jeebie99

Chieftain
Joined
Jul 20, 2021
Messages
7
I've been fiddling around with these two modifications I want to make to Cleopatra's leader ability, but so far I've nothing to show for it. I didn't expect to get stumped on something that seemed simple, but alas.

I'm trying to change the amount of bonus gold she receives from international trade routes to +2 instead of +4, and update the ability's text description, as well.

This is what I made for altering the modifier itself.

Code:
UPDATE ModifierArguments SET Value=2 WHERE ModifierId='TRAIT_INTERNATIONAL_TRADE_GAIN_GOLD' AND Name='Amount';

And this is what I tried to do for altering the ability's description.

Code:
UPDATE LocalizedText SET Text='Your [ICON_TradeRoute] Trade Routes to other civilizations provide +2 [ICON_Gold] Gold for Egypt. Other civilizations'' [ICON_TradeRoute] Trade Routes to Egypt provide +2 [ICON_Food] Food for them and +2 [ICON_Gold] Gold for Egypt.' WHERE Language=en_US AND Tag='LOC_TRAIT_LEADER_MEDITERRANEAN_DESCRIPTION';

https://pastebin.com/9vVfMQUz

Here's my Modding log, if that helps.
 

LeeS

Imperator
Joined
Jul 23, 2013
Messages
7,241
Location
Illinois, USA
Code:
[3298668.934] Loading Mod - C:/Users/gmnjr/Documents/My Games/Sid Meier's Civilization VI/Mods/Egypt and Cleopatra Mod/Egypt and Cleopatra Mod.modinfo
[3298668.936] ERROR: Invalid file reference in action, did you forgot to add it in <Files>? - Ruler_Cleopatra.sql

In addition to what is in Modding.log, what is in Database.log ?
 

LeeS

Imperator
Joined
Jul 23, 2013
Messages
7,241
Location
Illinois, USA
Looks like your modinfo file does not list a file called Ruler_Cleopatra.sql in the <Files> section, which it must in order for the game to find the file. So there is no database error associated with it because the code within the SQL file never attempts to load into the game.

The code itself here looks OK to me
Code:
UPDATE ModifierArguments SET Value=2 WHERE ModifierId='TRAIT_INTERNATIONAL_TRADE_GAIN_GOLD' AND Name='Amount';
This however is probably not being executed because of the goofy way that localized text works:
Code:
UPDATE LocalizedText SET Text='Your [ICON_TradeRoute] Trade Routes to other civilizations provide +2 [ICON_Gold] Gold for Egypt. Other civilizations'' [ICON_TradeRoute] Trade Routes to Egypt provide +2 [ICON_Food] Food for them and +2 [ICON_Gold] Gold for Egypt.' WHERE Language=en_US AND Tag='LOC_TRAIT_LEADER_MEDITERRANEAN_DESCRIPTION';
Here though you have a double appostrophe so the SQL parser is probably seeing the first appostrophe as the termination of the text string
Code:
Other civilizations''
I don't see any error in database.log related to this, however, so are you loading the SQL file with your LocalizedText update in an UpdateText action ?

Also, 'en_US' rather than en_US.

A more basic issue with using UPDATE on localizedtext is that often it does not function correctly because LocalizedText is not a true SQL table in the usual sense. Usually it is easier to use INSERT OR REPLACE INTO syntax when altering LocalizedText Tags.
Code:
INSERT OR REPLACE INTO LocalizedText (Tag, Language, Text)
VALUES	('LOC_TRAIT_LEADER_MEDITERRANEAN_DESCRIPTION', 'en_US',"Your [ICON_TradeRoute] Trade Routes to other civilizations provide +2 [ICON_Gold] Gold for Egypt. Other civilizations' [ICON_TradeRoute] Trade Routes to Egypt provide +2 [ICON_Food] Food for them and +2 [ICON_Gold] Gold for Egypt.");
 

Jeebie99

Chieftain
Joined
Jul 20, 2021
Messages
7
Yeah, the LocalizedText update is an UpdateText action.

I looked in my modinfo file and it seems that both files are in the <Files> section, so I'm not sure why I'm getting that error.

Edit: Turns out I didn't change the In-Game actions to reflect the new file I made for modifying cleopatra's trait, since I deleted the old one. I fixed that but even with the code you gave me to fix the LocalizedText update it still doesn't work.
 
Last edited:

LeeS

Imperator
Joined
Jul 23, 2013
Messages
7,241
Location
Illinois, USA
Appears to be a LoadOrder issue for the text. Altering the modifino as follows took care of the issue for me
Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="b2a8fe07-14ae-438a-87a1-b214d49fb0fd" version="1">
  <Properties>
    <Name>Egypt and Cleopatra Mod</Name>
    <Description>My first attempt at creating a mod.</Description>
    <Created>1627014067</Created>
    <Teaser>My first attempt at creating a mod.</Teaser>
    <Authors>Jeebie99</Authors>
    <CompatibleVersions>1.2,2.0</CompatibleVersions>
  </Properties>
  <FrontEndActions>
    <UpdateText id="UpdateRulerTraitText">
      <File>LeaderTraitText.sql</File>
    </UpdateText>
  </FrontEndActions>
  <InGameActions>
    <UpdateDatabase id="UpdateRulerTrait">
      <Properties>
        <LoadOrder>150</LoadOrder>
      </Properties>
      <File>CleopatraTrait.sql</File>
    </UpdateDatabase>
    <UpdateText id="UpdateRulerTraitText">
      <Properties>
        <LoadOrder>150</LoadOrder>
      </Properties>
      <File>LeaderTraitText.sql</File>
    </UpdateText>
  </InGameActions>
  <Files>
    <File>CleopatraTrait.sql</File>
    <File>LeaderTraitText.sql</File>
  </Files>
</Mod>
You can add a LoadOrder setting as a custom property of an action in Modbuddy and it will generate the code for the LoadOrder setting in the Modinfo file for you.

Note as insurance I also added a LoadOrder setting to the UpdateDatabase action as well.
 

Jeebie99

Chieftain
Joined
Jul 20, 2021
Messages
7
It's still not updating the text, do you think I should just try reinstalling the game? That's about the only thing I can think of that might be the problem, if it worked fine for you.
 

LeeS

Imperator
Joined
Jul 23, 2013
Messages
7,241
Location
Illinois, USA

LeeS

Imperator
Joined
Jul 23, 2013
Messages
7,241
Location
Illinois, USA
Ah. Yes. That would be it. I tested with Vanilla because I've been running a huge map heavily modded Vanilla game lately to confirm that Vanilla does not cause some of the asset limit and other issues people have been reporting with large maps / heavily modded game assets / etc.

My bad for not thinking to check the Tags used by the expansions.
 
Top Bottom