What the heck is wrong with my Shipyard mod?

pokiehl

Deity
Joined
Mar 5, 2017
Messages
2,751
I uploaded a mod to steam to improve coastal cities, inspired by TCS. For the shipyard building, it's suppose dto remove the default production bonus, add +1 housing, add +2 food, +1 production, and +1 gold, and add +1 production to fishing boats.

The only aspect that worked is the removal of the default production bonus. I have no idea why this isn't working. Here is the code:

Code:
--Remove default production bonus from Shipyards
DELETE FROM Building_YieldDistrictCopies WHERE BuildingType = 'BUILDING_SHIPYARD' ;

--Shipyards now grant +1 housing
UPDATE Buildings SET Housing = '1' WHERE BuildingType = 'BUILDING_SHIPYARD' ;

--Shipyards now yield +2 food, +1 production, and +1 gold
INSERT INTO Building_YieldChanges (BuildingType, YieldType, YieldChange) VALUES ('BUILDING_SHIPYARD', 'YIELD_FOOD', '2') ;
INSERT INTO Building_YieldChanges (BuildingType, YieldType, YieldChange) VALUES ('BUILDING_SHIPYARD', 'YIELD_GOLD', '1') ;
INSERT INTO Building_YieldChanges (BuildingType, YieldType, YieldChange) VALUES ('BUILDING_SHIPYARD', 'YIELD_PRODUCTION', '1') ;

--Shipyards now grant +1 production to fishing boats
INSERT INTO Modifiers (ModifierId, ModifierType, SubjectRequirementSetId) VALUES ('P_SHIPYARD_BOATPROD','MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD', 'P_TILE_HAS_BOAT') ;
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES ('P_SHIPYARD_BOATPROD', 'YieldType', 'YIELD_PRODUCTION') ;
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES ('P_SHIPYARD_BOATPROD', 'Amount', '1') ;
INSERT INTO BuildingModifiers (BuildingType, ModifierID) VALUES ('BUILDING_SHIPYARD', 'P_SHIPYARD_BOATPROD') ;

Higher in the code, I added a modifier for Lighthouses to add +1 food to fishing boats, which worked. That's where I added the Requirements sets. Here's the lighthouse code:
Code:
INSERT INTO Requirements (RequirementId, RequirementType) VALUES ('P_REQUIRES_BOAT', 'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES') ;
INSERT INTO RequirementArguments (RequirementId, Name, Value) VALUES ('P_REQUIRES_BOAT', 'ImprovementType', 'IMPROVEMENT_FISHING_BOATS') ;
INSERT INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('P_TILE_HAS_BOAT', 'REQUIREMENTSET_TEST_ALL') ;
INSERT INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('P_TILE_HAS_BOAT', 'P_REQUIRES_BOAT') ;
INSERT INTO Modifiers (ModifierId, ModifierType, SubjectRequirementSetId) VALUES ('P_LIGHTHOUSE_BOATFOOD','MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD', 'P_TILE_HAS_BOAT') ;
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES ('P_LIGHTHOUSE_BOATFOOD', 'YieldType', 'YIELD_FOOD') ;
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES ('P_LIGHTHOUSE_BOATFOOD', 'Amount', '1') ;
INSERT INTO BuildingModifiers (BuildingType, ModifierID) VALUES ('BUILDING_LIGHTHOUSE', 'P_LIGHTHOUSE_BOATFOOD') ;

I'm pretty certain I don't need to have the Requirements/Req Arguments/Req Sets/ReqSetReqs again.
 
Check your log files, particularly the database.log. If the update function for the Buildings table has incorrect syntax or breaks something when trying to apply it to the database, the rest of the file won't be applied either. To check if it is the problem, move that line of code to the bottom of the file, rebuild it, and the other stuff works at that point, you know that it's that line breaking something.
 
Thank you so much luei333! Looking in that helped me find the issue quickly. You're awesome
 
For stuff like this you can also pre-run the code in SQLite. I just tried it and got a Foreign Key constraint fail. SQLite gives you more explicit messages than the game does in a lot of cases, like in this one:

[06:52:30] Error while executing SQL query on database 'DebugGameplay': UNIQUE constraint failed: Building_YieldChanges.BuildingType, Building_YieldChanges.YieldType

The issue I presume is you used INSERT for the Building yields, but yields of that type already exist in the database. You either need to delete them first and then apply, or use UPDATE.
 
You should also be able to use "Replace" syntax when you are not sure if there is already an interfering "Unique Row" within the table:
Code:
INSERT OR REPLACE INTO Building_YieldChanges (BuildingType, YieldType, YieldChange) VALUES ('BUILDING_SHIPYARD', 'YIELD_PRODUCTION', 1);
The XML version of this is to simply use <Replace> -- </Replace> instead of <Row> -- </Row>
  1. Replace syntax only works properly on tables that have primary keys, though.
  2. The nice thing is that Civ6 has a PRIMARY KEY(ColumnName) designation for nearly all the tables used. There are a few exceptions but I generally check the table schemas here for "in-game" stuff before deciding on how I am going to syntax my code: C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\Gameplay\Data\Schema/01_GameplaySchema.sql
 
Top Bottom