1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Mod not working

Discussion in 'Mod Creation Help' started by JerryZ, Sep 15, 2018.

Tags:
  1. JerryZ

    JerryZ Chieftain

    Joined:
    Sep 7, 2018
    Messages:
    12
    Hi everyone, I have created my second mod, but for some reason, the mod is refuse to work. I use .sql this time just to see the difference between .xml and .sql. And I have this error,
    Code:
    [3700875.328] [Configuration]: Validating Foreign Key Constraints...
    [3700875.329] [Configuration]: Passed Validation.
    [3700895.904] [Gameplay] ERROR: table Resource_YieldChanges has no column named TerrainType
    [3700895.928] [Gameplay]: Validating Foreign Key Constraints...
    [3700895.942] [Gameplay]: Passed Validation.
    I have attached the mod in discussion.
     

    Attached Files:

  2. Laurana Kanan

    Laurana Kanan Queen's

    Joined:
    Apr 10, 2014
    Messages:
    1,046
    Gender:
    Female
    Location:
    Near the Greatest Snow on Earth
    In the Resource_YieldChanges table you have TerrainType as a column, which does not exist. The proper column is ResourceType for that table. If you want to change the yield for terrain, the proper table is Terrain_YieldChanges.
     
  3. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,563
    Location:
    Illinois, USA
    These are syntax errors as well
    Code:
    --Improvement New
    INSERT INTO ImprovementType (ImprovementType, YieldType, YieldChange) VALUES ('IMPROVEMENT_FARM', 'YIELD_PRODUCTION', '3');
    INSERT INTO ImprovementType (ImprovementType, YieldType, YieldChange) VALUES ('FISHING_BOATS', 'YIELD_PRODUCTION', '3');
    INSERT INTO ImprovementType (ImprovementType, YieldType, YieldChange) VALUES ('PLANTATION', 'YIELD_PRODUCTION', '3');
    
    Update ResourceType Set YieldChange = '5' Where ResourceType="RESOURCE_STONE"
    Update ResourceType Set YieldChange = '4' Where ResourceType="RESOURCE_DEER"
    
    Update Resource Type Set YieldChange = '4' Where ResourceType="RESOURCE_IVORY"
    Update Resource Type Set YieldChange = '4' Where ResourceType="RESOURCE_GYPSUM"
    Update Resource Type Set YieldChange = '4' Where ResourceType="RESOURCE_WHALES"
    
    Update Resource Type Set YieldChange = '10' Where ResourceType="RESOURCE_COAL"
    Update Resource Type Set YieldChange = '5' Where ResourceType="RESOURCE_HORSES"
    Update Resource Type Set YieldChange = '10' Where ResourceType="RESOURCE_NITER"
    Update Resource Type Set YieldChange = '15' Where ResourceType="RESOURCE_OIL"
    Update Resource Type Set YieldChange = '20' Where ResourceType="RESOURCE_URANIUM"
    You are attempting to create updates and inserts into non-existant tables, and you are missing the required chunk end character ; at the end of each of the update attempts
     
  4. JerryZ

    JerryZ Chieftain

    Joined:
    Sep 7, 2018
    Messages:
    12
    I have got a new error code
    Code:
    [3730229.797] [Configuration]: Passed Validation.
    [3730246.503] [FullTextSearch]: FTS - Creating Context
    [3730254.307] [Gameplay] ERROR: near "(": syntax error
    [3730254.329] [Gameplay]: Validating Foreign Key Constraints...
    [3730254.343] [Gameplay]: Passed Validation.
    and i look over all of my parentheses but nothing seem to be out of ordinary.
     
  5. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,563
    Location:
    Illinois, USA
    UPDATE syntax here is also incorrect
    Code:
    Update Resource_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_GRASS_HILLS', 'YIELD_PRODUCTION', '2') ;
    Update Resource_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_PLAINS', 'YIELD_PRODUCTION', '2') ;
    Update Resource_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_PLAINS_HILLS', 'YIELD_PRODUCTION', '3') ;
    Update Resource_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_TUNDRA_HILLS', 'YIELD_PRODUCTION', '2') ;
    Update Resource_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_SNOW_HILLS', 'YIELD_PRODUCTION', '2') ;
    Update Resource_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_DESERT_HILLS', 'YIELD_PRODUCTION', '2') ;
    Which I did not spot the first time looking at the code.

    In this first chunk of code you are using the syntax that would normally be used for an INSERT INTO rather than the syntax for an UPDATE

    INSERT INTO:
    Code:
    INSERT INTO TableName (ColumnName1, ColumnName2, ColumnName_N) VALUES (ValueForColumnName1, ValueForColumnName2, ValueForColumnName_N);
    INSERT INTO adds a new row in the specified table.


    UPDATE:
    Code:
    UPDATE TableName SET ColumnName1 = NewValueForColumnName1 WHERE ColumnName2 = ValueForMatchingTheUpdate ;
    UPDATE alters the data in an existing and "matching" row in the table. If nothing "matches-up" to the data in the WHERE portion of the UPDATE, nothing is done.

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

    'near' in database.log messages means just before the indicated "text-string". For your error message the character ( is the "text-string". And since there are multiple ( characters in your file you have to look for errors just before all of them, including an incorrectly-used primary-statement such as UPDATE
     
    Last edited: Sep 15, 2018
  6. JerryZ

    JerryZ Chieftain

    Joined:
    Sep 7, 2018
    Messages:
    12
    Thanks a lot for all those advise, do you know any way which you can identify the table name or the column.
     
  7. JerryZ

    JerryZ Chieftain

    Joined:
    Sep 7, 2018
    Messages:
    12
    And then I found 'DB Browser for SQLite' and now the problem with looking for table name has gone away
     
  8. JerryZ

    JerryZ Chieftain

    Joined:
    Sep 7, 2018
    Messages:
    12
    Have you ever <update> the code but it does nothing in the game, and neither logs gives any error massages
    here is the code I'm try to figure out,
    Code:
    --Terrain New
    INSERT INTO Terrain_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_GRASS', 'YIELD_PRODUCTION', '10') ;
    INSERT INTO Terrain_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_TUNDRA', 'YIELD_PRODUCTION', '1') ;
    INSERT INTO Terrain_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_COAST', 'YIELD_PRODUCTION', '1') ;
    INSERT INTO Terrain_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_OCEAN', 'YIELD_PRODUCTION', '1') ;
    INSERT INTO Terrain_YieldChanges (TerrainType, YieldType, YieldChange) VALUES ('TERRAIN_DESERT', 'YIELD_PRODUCTION', '1') ;
    --Terrain Update
    Update Terrain_YieldChanges Set YieldChange = '20' Where TerrainType='Terrain_GRASS_HILLS' ;
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='Terrain_PLAINS' ;
    Update Terrain_YieldChanges Set YieldChange = '3' Where TerrainType='Terrain_PLAINS_HILLS' ;
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='Terrain_TUNDRA_HILLS' ;
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='Terrain_SNOW_HILLS' ;
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='Terrain_DESERT_HILLS' ;
    the <insert into> part functions fine, but the update section have not effect on the game. I run the test with rest of mod disabled, and I have tried to use <insert into> for the update section, but return with fail to launch the game.
     
  9. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,563
    Location:
    Illinois, USA
    'Terrain_GRASS_HILLS' != 'TERRAIN_GRASS_HILLS'

    Tags must exactly match. There cannot be even the smallest mismatch in spelling or capitalization. Your SQL UPDATE commands fail because there is nothing in any game-table called 'Terrain_GRASS_HILLS', etc.
     
  10. JerryZ

    JerryZ Chieftain

    Joined:
    Sep 7, 2018
    Messages:
    12
    Thanks for the help and you are really good at this. Do you know any ways where I can set up two Where (condition) for a single <update>
     
  11. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,563
    Location:
    Illinois, USA
    SQL
    Code:
    UPDATE Building_YieldChanges
    SET YieldChange = 2
    WHERE BuildingType = 'BUILDING_LIGHTHOUSE' AND YieldType = 'YIELD_GOLD';
    XML
    Code:
    <GameData>
    	<Building_YieldChanges>
    		<Update>
    			<Where BuildingType="BUILDING_LIGHTHOUSE" YieldType="YIELD_GOLD" />
    			<Set YieldChange="2"/>
    		</Update>
    	</Building_YieldChanges>
    </GameData>
     
  12. JerryZ

    JerryZ Chieftain

    Joined:
    Sep 7, 2018
    Messages:
    12
    I tried the code but i got an error message
    Code:
    [4179133.377] [Configuration]: Validating Foreign Key Constraints...
    [4179133.377] [Configuration]: Passed Validation.
    [4179170.026] [Gameplay] ERROR: UNIQUE constraint failed: Resource_YieldChanges.ResourceType, Resource_YieldChanges.YieldType
    [4179170.026] [Gameplay] ERROR: UNIQUE constraint failed: Resource_YieldChanges.ResourceType, Resource_YieldChanges.YieldType
    [4179170.049] [Gameplay]: Validating Foreign Key Constraints...
    [4179170.064] [Gameplay]: Passed Validation.
    And here is what my code looks like
    Code:
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='TERRAIN_GRASS_HILLS' AND YieldType='YIELD_PRODUCTION' ;
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='TERRAIN_PLAINS' AND YieldType='YIELD_PRODUCTION' ;
    Update Terrain_YieldChanges Set YieldChange = '3' Where TerrainType='TERRAIN_PLAINS_HILLS' AND YieldType='YIELD_PRODUCTION' ;
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='TERRAIN_TUNDRA_HILLS' AND YieldType='YIELD_PRODUCTION' ;
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='TERRAIN_SNOW_HILLS' AND YieldType='YIELD_PRODUCTION' ;
    Update Terrain_YieldChanges Set YieldChange = '2' Where TerrainType='TERRAIN_DESERT_HILLS' AND YieldType='YIELD_PRODUCTION' ;
    --Improvement Update
    Update Improvement_YieldChanges Set YieldChange = '10' Where ImprovementType='IMPROVEMENT_MINE' AND YieldType='YIELD_PRODUCTION' ;
    Update Improvement_YieldChanges Set YieldChange = '10' Where ImprovementType='IMPROVEMENT_QUARRY' AND YieldType='YIELD_PRODUCTION' ;
    Update Improvement_YieldChanges Set YieldChange = '5' Where ImprovementType='IMPROVEMENT_PASTURE' AND YieldType='YIELD_PRODUCTION' ;
    Update Improvement_YieldChanges Set YieldChange = '5' Where ImprovementType='IMPROVEMENT_CAMP' AND YieldType='YIELD_PRODUCTION' ;
    Update Improvement_YieldChanges Set YieldChange = '40' Where ImprovementType='IMPROVEMENT_LUMBER_MILL' AND YieldType='YIELD_PRODUCTION' ;
    Update Improvement_YieldChanges Set YieldChange = '15' Where ImprovementType='IMPROVEMENT_OIL_WELL' AND YieldType='YIELD_PRODUCTION' ;
    Update Improvement_YieldChanges Set YieldChange = '15' Where ImprovementType='IMPROVEMENT_OFFSHORE_OIL_RIG' AND YieldType='YIELD_PRODUCTION' ;
     
  13. pokiehl

    pokiehl Chieftain

    Joined:
    Mar 5, 2017
    Messages:
    252
    Your errors are with the Resource_YieldChanges table, not any part of that code.
     
  14. JerryZ

    JerryZ Chieftain

    Joined:
    Sep 7, 2018
    Messages:
    12
    If you are referring to the errors in the first version, it has already been fixed. The latest version is in the attachment. Currently I'm dealing with <update> changing the wrong yield.
     

    Attached Files:

  15. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,563
    Location:
    Illinois, USA
    These errors
    Code:
    [4179170.026] [Gameplay] ERROR: UNIQUE constraint failed: Resource_YieldChanges.ResourceType, Resource_YieldChanges.YieldType
    [4179170.026] [Gameplay] ERROR: UNIQUE constraint failed: Resource_YieldChanges.ResourceType, Resource_YieldChanges.YieldType
    Means that in table Resource_YieldChanges an attempt was made to add a new row with a combination of ResourceType and YieldType
    that already exists within the Resource_YieldChanges table.

    The database will not allow a repeat of a combination of ResourceType, YieldType that has already been given in the base game, and in any expansion, or DLC, or any other mod that has already loaded its code.

    This is the definition of the Resource_YieldChanges table as defined by Firaxis in the game's base files:
    Code:
    CREATE TABLE "Resource_YieldChanges" (
    		"ResourceType" TEXT NOT NULL,
    		"YieldType" TEXT NOT NULL,
    		"YieldChange" INTEGER NOT NULL,
    		PRIMARY KEY(ResourceType, YieldType),
    		FOREIGN KEY (ResourceType) REFERENCES Resources(ResourceType) ON DELETE CASCADE ON UPDATE CASCADE,
    		FOREIGN KEY (YieldType) REFERENCES Yields(YieldType) ON DELETE CASCADE ON UPDATE CASCADE);
    The line
    Code:
    PRIMARY KEY(ResourceType, YieldType),
    instructs the game's database to not accept any combination of data for columns ResourceType and YieldType that have been previously entered into the game's database. Any such repeat of an existing combination will cause a fatal error to the file where the game finds this repeat, and nothing further from within that file will be added to the game.

    Use your SQL viewer program to open file DebugGameplay.sqlite in the folder ~\Documents\My Games\Sid Meier's Civilization VI\Cache. Then look at the contents of table Resource_YieldChanges to see which combinations of ResourceType, YieldType are already in the database by the time your code attempts to execute.
     

Share This Page

Ebates: Get Paid to Shop