Changing the descritpion of an improvement

TTSev

Chieftain
Joined
Oct 25, 2019
Messages
28
Hi,

I have another question, hopefully simpler.
I'm working on a mod that changes some improvements' base yield and bonus yield.
For example, for the camp I have that (which based on my express testing seems to work):
Code:
<GameData>
    <!--
       Camps changes
           +1 food (from +2 gold)
           +1 gold at Mercantilism (from +1 production)
           +1 production at Gunpowder (new)
           +1 production at Synthetic Materials (from +2 gold)
           +2 gold at Professional Sports (new)
           +1 culture at Environmentalism (new)
   -->
   <Improvement_YieldChanges>

       <Delete ImprovementType="IMPROVEMENT_CAMP" YieldType="YIELD_GOLD" YieldChange="2" />
       <Delete ImprovementType="IMPROVEMENT_CAMP" YieldType="YIELD_FOOD" YieldChange="0" />

       <Row ImprovementType="IMPROVEMENT_CAMP"
            YieldType="YIELD_FOOD"
            YieldChange="1" />
       <Row ImprovementType="IMPROVEMENT_CAMP"
            YieldType="YIELD_GOLD"
            YieldChange="0" />

   </Improvement_YieldChanges>
   <Improvement_BonusYieldChanges>
       
       <Delete Id="1" ImprovementType="IMPROVEMENT_CAMP" YieldType="YIELD_PRODUCTION" BonusYieldChange="1" PrereqCivic="CIVIC_MERCANTILISM" />
       <Delete Id="100" ImprovementType="IMPROVEMENT_CAMP" YieldType="YIELD_FOOD" BonusYieldChange="1" PrereqCivic="CIVIC_MERCANTILISM" />
       <Delete Id="2" ImprovementType="IMPROVEMENT_CAMP" YieldType="YIELD_GOLD" BonusYieldChange="2" PrereqTech="TECH_SYNTHETIC_MATERIALS" />
       <Delete Id="225" ImprovementType="IMPROVEMENT_CAMP" YieldType="YIELD_GOLD" BonusYieldChange="2" PrereqTech="TECH_SYNTHETIC_MATERIALS" />

       <Row Id="1"
            ImprovementType="IMPROVEMENT_CAMP"
            YieldType="YIELD_GOLD"
            BonusYieldChange="1"
            PrereqCivic="CIVIC_MERCANTILISM" />
       <Row Id="2"
            ImprovementType="IMPROVEMENT_CAMP"
            YieldType="YIELD_PRODUCTION"
            BonusYieldChange="1"
            PrereqTech="TECH_GUNPOWDER"/>
       <Row Id="100"
            ImprovementType="IMPROVEMENT_CAMP"
            YieldType="YIELD_PRODUCTION"
            BonusYieldChange="1"
            PrereqTech="TECH_SYNTHETIC_MATERIALS"/>
       <Row Id="225"
            ImprovementType="IMPROVEMENT_CAMP"
            YieldType="YIELD_GOLD"
            BonusYieldChange="2"
            PrereqCivic="CIVIC_PROFESSIONAL_SPORTS"/>
       <Row ImprovementType="IMPROVEMENT_CAMP"
            YieldType="YIELD_CULTURE"
            BonusYieldChange="1"
            PrereqCivic="CIVIC_ENVIRONMENTALISM"/>       

   </Improvement_BonusYieldChanges>

</GameData>
In the ingame descritpion, I have the correct things displayed for the 'gameplay desscritpion' but the base description stills says +2 gold:
DZk2W5R.png

To change that, I added an sql file in the mod with this line:
Code:
UPDATE LocalizedText SET Text='Unlocks the Builder ability to construct Camps.[NEWLINE]+1 [ICON_Food] Food. Can only be built on valid resources.[NEWLINE]If built on Luxury resources, the city will gain use of that resource.' WHERE Tag='LOC_IMPROVEMENT_CAMP_DESCRIPTION' AND Language='en_US';
But it doesn't work and the database.log tells me "[231662.496] [Gameplay] ERROR: no such table: LocalizedText" which surprises me because that table exists to my knowledge.

I don't know programming and I'm new to modding, so it's probably something stupid but I'm lost here.
 
You are attempting your SQL code via an UpdateDatabase type of action. Hence the "[Gameplay]" in the error message.

Text alterations or additions need to be conducted by an "UpdateText" type of action.
 
Thanks for your help!
So I don't get any errors in the database.log but the change is still not applied.
I tried both:
Code:
UPDATE LocalizedText SET Text='PLOP' WHERE Tag='LOC_IMPROVEMENT_CAMP_DESCRIPTION' AND Language='en_US';
and:
Code:
REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_IMPROVEMENT_CAMP_DESCRIPTION', 'PLOP');

Here's the modinfo:
Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="f153009a-9e9e-4967-bace-0ef3fa22390b" version="1">
  <Properties>
    <Name>SPMs Improvement Yields</Name>
    <Description>Test. Attempt at balancing improvements.</Description>
    <Created>1572210223</Created>
    <Teaser>Test. Attempt at balancing improvements.</Teaser>
    <Authors>SuperPinkyMan</Authors>
    <AffectsSavedGames>0</AffectsSavedGames>
    <CompatibleVersions>1.2,2.0</CompatibleVersions>
  </Properties>
  <FrontEndActions />
  <InGameActions>
    <UpdateText id="Text">
      <File>SPM_ Improvement_Yields_Text.sql</File>
    </UpdateText>
    <UpdateDatabase id="Improvements">
      <File>SPM_ Improvement_Yields.xml</File>
    </UpdateDatabase>
  </InGameActions>
  <Files>
    <File>SPM_ Improvement_Yields.xml</File>
    <File>SPM_ Improvement_Yields_Text.sql</File>
  </Files>
</Mod>
 
Eliminate the spaces in the names of the files. The game tends to very much not like spaces in file names.

Try
Code:
    <UpdateText id="Text">
      <Properties>
        <LoadOrder>150</LoadOrder>
      </Properties>
      <File>SPM_Improvement_Yields_Text.sql</File>
    </UpdateText>
LoadOrder is specified as a Custom Property of an Action.

Either of
Code:
UPDATE LocalizedText SET Text='PLOP' WHERE Tag='LOC_IMPROVEMENT_CAMP_DESCRIPTION' AND Language='en_US';
or
Code:
INSERT OR REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_IMPROVEMENT_CAMP_DESCRIPTION', 'PLOP');
would be correct syntax.

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

However the game seems to often ignore updating to base game text "Tags" because of the way the Localized Text database works. Added to this is the relative Loading Order of mods and the expansions. If one's code loads before Gathering Storm loads, for example, the code from the mod is over-written in many cases by Gathering Storm loading its data. Setting a LoadOrder value for the UpdateText action is intended to ensure the mod's code loads after Gathering Storm and Rise and Fall, but does not always work with UpdateText actions because all the Localized and BaseGame text "tables" are not actually true SQL database tables, they are "views", which operate differently than true SQL tables. So it is often necessary to re-direct to a different Tag in the definition of the Improvement, Building, District, etc. In the "normal" xml code:
Code:
<GameData>
	<Improvements>
		<Update>
			<Where ImprovementType="IMPROVEMENT_CAMP" />
			<Set Description="LOC_IMPROVEMENT_CAMP_DESCRIPTION_NEW" />
		</Update>
	</Improvements>
</GameData>
Then in the text SQL file
Code:
INSERT OR REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_IMPROVEMENT_CAMP_DESCRIPTION_NEW', 'PLOP');
 
Amazing! Thanks a lot for your time.
The loadorder on text didn't have any effect but your other method with defining a new description worked perfectly!
 
I'm back again with a few follow up questions.
1) I also had to change the descriptions of techs and civics and I have issues with the civics.
One of the techs (stirrups) doesn't have a description in the game so I added the following in the xml file for updatedatabase:
Code:
    <Technologies>
        <Update>   
            <Where TechnologyType="TECH_STIRRUPS" />
            <Set Description="LOC_TECH_STIRRUPS_DESCRIPTION" />
        </Update>
    </Technologies>
And the following in the sql one for the updatetext:
Code:
INSERT OR REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_TECH_STIRRUPS_DESCRIPTION', '+1 [ICON_Food] Food from the Pasture improvement.');
And it worked fine.
But I tried the same for civics and it didn't work:
Code:
    <Civics>
        <Update>
            <Where CivicType="CIVIC_CAPITALISM" />
            <Set Description="LOC_CIVIC_CAPITALISM_DESCRIPTION" />
            <Where CivicType="CIVIC_PROFESSIONAL_SPORTS" />
            <Set Description="LOC_CIVIC_PROFESSIONAL_SPORTS_DESCRIPTION" />
            <Where CivicType="CIVIC_SPACE_RACE" />
            <Set Description="LOC_CIVIC_SPACE_RACE_DESCRIPTION" />
            <Where CivicType="CIVIC_SOCIAL_MEDIA" />
            <Set Description="LOC_CIVIC_SOCIAL_MEDIA_DESCRIPTION" />
        </Update>
    </Civics>
Code:
INSERT OR REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_CIVIC_CAPITALISM_DESCRIPTION', '+1 [ICON_Gold] gold from the Lumber mill improvement.');
INSERT OR REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_CIVIC_PROFESSIONAL_SPORTS_DESCRIPTION', '+2 [ICON_Gold] gold from the Camp improvement.');
INSERT OR REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_CIVIC_SPACE_RACE_DESCRIPTION', '+2 [ICON_Gold] gold from the Lumber mill improvement.');
INSERT OR REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_CIVIC_SOCIAL_MEDIA_DESCRIPTION', '+1 [ICON_Science] science from the Quarry improvements and +1 [ICON_Culture] culture from the Pasture improvement.');
Nothing gets added and I have an error in database.log
[411175.107] [Gameplay] ERROR: Database::XMLSerializer (SPM_Improvement_Yields.xml): Duplicate <Set> elements are not allowed.
[411175.107] [Gameplay]: In XMLSerializer while updating table Civics from file SPM_Improvement_Yields.xml.

2) Also, for some I had to remove the existing description, which I did this way:
Code:
INSERT OR REPLACE INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_TECH_ROBOTICS_DESCRIPTION', '');
The result is ok but the icon stays here just nothing pops up when I hover over it:
gDg4HVU.png

Is it possible to remove that thing easily?

3) Finally, I play with the game in French when I'm not testing mods, how do I place an apostrophe or a letter with accent in the description text? Apostrophe are an issu since it's the character used to define the start and end of the description and the letters with accent do not appear correctly ingame, I have a crossed box instead.
 
#1

Your problem is incorrect XML syntax:
Code:
<Civics>
        <Update>
            <Where CivicType="CIVIC_CAPITALISM" />
            <Set Description="LOC_CIVIC_CAPITALISM_DESCRIPTION" />
            <Where CivicType="CIVIC_PROFESSIONAL_SPORTS" />
            <Set Description="LOC_CIVIC_PROFESSIONAL_SPORTS_DESCRIPTION" />
            <Where CivicType="CIVIC_SPACE_RACE" />
            <Set Description="LOC_CIVIC_SPACE_RACE_DESCRIPTION" />
            <Where CivicType="CIVIC_SOCIAL_MEDIA" />
            <Set Description="LOC_CIVIC_SOCIAL_MEDIA_DESCRIPTION" />
        </Update>
    </Civics>
Each <Update> --- </Update> pair can only contain one <Where> and one <Set> clause. The correct syntax would be:
Code:
<Civics>
        <Update>
            <Where CivicType="CIVIC_CAPITALISM" />
            <Set Description="LOC_CIVIC_CAPITALISM_DESCRIPTION" />
        </Update>
        <Update>
           <Where CivicType="CIVIC_PROFESSIONAL_SPORTS" />
            <Set Description="LOC_CIVIC_PROFESSIONAL_SPORTS_DESCRIPTION" />
        </Update>
        <Update>
            <Where CivicType="CIVIC_SPACE_RACE" />
            <Set Description="LOC_CIVIC_SPACE_RACE_DESCRIPTION" />
        </Update>
        <Update>
            <Where CivicType="CIVIC_SOCIAL_MEDIA" />
            <Set Description="LOC_CIVIC_SOCIAL_MEDIA_DESCRIPTION" />
        </Update>
</Civics>
-------------------------

I am not sure I understand what it is you are trying to do for #2

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

#3

Code:
<GameData>
  <LocalizedText>
    <Replace Tag="LOC_PROMOTION_CLASS_NAVAL_RANGED_NAME" Language="fr_FR">
      <Text>Combat à distance en mer</Text>
      <Gender>masculine</Gender>
      <Plurality>1</Plurality>
    </Replace>
  </LocalizedText>
</GameData>
XML Replace is equal to SQL INSERT OR REPLACE INTO. Text can be entered from a mod using either of XML or SQL.
 
Again, thanks a lot for your help LeeS.
What I meant for #2:
gDg4HVU.png

Next to the death robot icon you see this star icon which is present when the tech or civic has a special bonus (+yield to improvements, adiitional spy, envoys, bonus tourism,...) and Robotics has one because it gives +1prod to pastures.
Since I wanted to get rid of this I wrote:
Code:
       <Replace Tag="LOC_TECH_ROBOTICS_DESCRIPTION" Language="en_US" >
           <Text></Text>
       </Replace>
Now the description is empty but the star icon remains and an empty tooltip pops when I mouse over it (that little thing over the word "Globalization" in the boost requirement). Is there an easy way to remove that star icon when the description is empty?
 
Is there an easy way to remove that star icon when the description is empty?
What you want to do is make the Description column for the TechnologyType in the Technologies table to be NULL. You could also get rid of the text too, but it's not necessary.
Code:
<Technologies>
    <Update>
        <Where TechnologyType="TECH_ROBOTICS"/>
        <Set>
            <Description></Description>
        </Set>
    </Update>
</Technologies>
 
Awesome, thanks again everyone! I should have everything I need now for this mod.
 
Back
Top Bottom