Mod not working

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.
 

Attachments

  • Much More Production.zip
    1.6 KB · Views: 197
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
 
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.
 
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:
Thanks a lot for all those advise, do you know any way which you can identify the table name or the column.
 
And then I found 'DB Browser for SQLite' and now the problem with looking for table name has gone away
 
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
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.
 
'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.
 
'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.
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>
 
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>
 
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>
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' ;
 
Your errors are with the Resource_YieldChanges table, not any part of that code.
 
Your errors are with the Resource_YieldChanges table, not any part of that code.
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.
 

Attachments

  • Much More Production.zip
    1.6 KB · Views: 194
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.
 
Top Bottom