What's wrong with this code?

Pikachaoomega

Chieftain
Joined
Jul 3, 2020
Messages
27
I've been trying to add to this Leader Ability one that needs requirements but I can't crack it. It always fails to load if I start a game. For context the code works fine with just the ability to build farms on desert, adding the district adjacency bonuses is where the problems come. I don't think I missed any syntax but I'm sure there's some errant comma i missed.


INSERT INTO Types
(Type, Kind )
VALUES ('TRAIT_LEADER_THIS_IS_THE_PLACE', 'KIND_TRAIT' );



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


INSERT INTO Traits
(TraitType, Name, Description )
VALUES ('TRAIT_LEADER_THIS_IS_THE_PLACE', 'LOC_TRAIT_LEADER_THIS_IS_THE_PLACE_NAME', 'LOC_TRAIT_LEADER_THIS_IS_THE_PLACE_DESCRIPTION' );

-----------------------------------------------
-- LeaderTraits

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

INSERT INTO LeaderTraits
(LeaderType, TraitType )
VALUES ('LEADER_BRIGHAM', 'TRAIT_LEADER_THIS_IS_THE_PLACE' ),
('LEADER_BRIGHAM', 'TRAIT_LEADER_RELIGIOUS_MAJOR_CIV');

-----------------------------------------------
-- Modifiers

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


INSERT INTO TraitModifiers
(TraitType, ModifierId )
VALUES ('TRAIT_LEADER_THIS_IS_THE_PLACE', 'MODIFIER_FARM_DESERT' ),
('TRAIT_LEADER_THIS_IS_THE_PLACE', 'MODIFIER_FARM_HOLY_SITE' ),
('TRAIT_LEADER_THIS_IS_THE_PLACE', 'MODIFIER_FARM_INDUSTRIAL_ZONE' );



INSERT INTO Modifiers
(ModifierId, ModifierType, RunOnce, Permanent )
VALUES ('MODIFIER_FARM_DESERT', 'MODIFIER_PLAYER_CITIES_ADJUST_IMPROVEMENT_VALID_TERRAIN', 0, 1 );
----
---
----
INSERT INTO Modifiers
(ModifierId, ModifierType, SubjectRequirementSetId)
VALUES ('MODIFIER_FARM_HOLY_SITE', 'MODIFIER_PLAYER_ADJUST_PLOT_YIELD', 'PLOT_ADJACENT_TO_HOLY_SITE_FARM_REQUIREMENTS'),
('MODIFIER_FARM_INDUSTRIAL_ZONE', 'MODIFIER_PLAYER_ADJUST_PLOT_YIELD', 'PLOT_ADJACENT_TO_INDUSTRIAL_ZONE_FARM_REQUIREMENTS');




INSERT INTO ModifierArguments
(ModifierId, Name, Value )
VALUES ('MODIFIER_FARM_DESERT', 'ImprovementType', 'IMPROVEMENT_FARM' ),
('MODIFIER_FARM_DESERT', 'TerrainType', 'TERRAIN_DESERT' ),
('MODIFIER_FARM_HOLY_SITE', 'YieldType', 'YIELD_FAITH' ),
('MODIFIER_FARM_HOLY_SITE', 'Amount', '1' ),
('MODIFIER_FARM_INDUSTRIAL_ZONE', 'YieldType', 'YIELD_PRODUCTION' ),
('MODIFIER_FARM_INDUSTRIAL_ZONE', 'Amount', '1' );



INSERT INTO RequirementSets
(RequirementSetId, RequirementSetType)
VALUES ('PLOT_ADJACENT_TO_HOLY_SITE_FARM_REQUIREMENTS', 'REQUIREMENTSET_TEST_ALL'),
('PLOT_ADJACENT_TO_INDUSTRIAL_ZONE_FARM_REQUIREMENTS', 'REQUIREMENTSET_TEST_ALL');


INSERT INTO RequirementSetRequirements

(RequirementSetId, RequirementId)

VALUES ('PLOT_ADJACENT_TO_HOLY_SITE_FARM_REQUIREMENTS', 'REQUIRES_PLOT_HAS_FARM'),
('PLOT_ADJACENT_TO_HOLY_SITE_FARM_REQUIREMENTS', 'REQUIRES_PLOT_ADJACENT_TO_HOLY_SITE'),

('PLOT_ADJACENT_TO_INDUSTIRAL_ZONE_FARM_REQUIREMENTS', 'REQUIRES_PLOT_HAS_FARM'),
('PLOT_ADJACENT_TO_INDUSTIRAL_ZONE_FARM_REQUIREMENTS', 'REQUIRES_PLOT_ADJACENT_TO_INDUSTRIAL_ZONE');



INSERT INTO Requirements
(RequirementId, RequirementType )
VALUES ('REQUIRES_PLOT_ADJACENT_TO_HOLY_SITE', 'REQUIREMENT_PLOT_ADJACENT_DISTRICT_TYPE_MATCHES'),
('REQUIRES_PLOT_ADJACENT_TO_INDUSTRIAL_ZONE', 'REQUIREMENT_PLOT_ADJACENT_DISTRICT_TYPE_MATCHES');


INSERT INTO RequirementArguments
(RequirementId, Name, Value)
VALUES ('REQUIRES_PLOT_ADJACENT_TO_HOLY_SITE', 'DistrictType', 'DISTRICT_HOLY_SITE'),
('REQUIRES_PLOT_ADJACENT_TO_INDUSTRIAL_ZONE', 'DistrictType', 'DISTRICT_INDUSTRIAL_ZONE');
 
Syntax Error is what is wrong. Specifically a typing mismatch:
Code:
INSERT INTO RequirementSets
(RequirementSetId, RequirementSetType)
VALUES ('PLOT_ADJACENT_TO_HOLY_SITE_FARM_REQUIREMENTS', 'REQUIREMENTSET_TEST_ALL'),
('PLOT_ADJACENT_TO_INDUSTRIAL_ZONE_FARM_REQUIREMENTS', 'REQUIREMENTSET_TEST_ALL');


INSERT INTO RequirementSetRequirements

(RequirementSetId, RequirementId)

VALUES ('PLOT_ADJACENT_TO_HOLY_SITE_FARM_REQUIREMENTS', 'REQUIRES_PLOT_HAS_FARM'),
('PLOT_ADJACENT_TO_HOLY_SITE_FARM_REQUIREMENTS', 'REQUIRES_PLOT_ADJACENT_TO_HOLY_SITE'),

('PLOT_ADJACENT_TO_INDUSTIRAL_ZONE_FARM_REQUIREMENTS', 'REQUIRES_PLOT_HAS_FARM'),
('PLOT_ADJACENT_TO_INDUSTIRAL_ZONE_FARM_REQUIREMENTS', 'REQUIRES_PLOT_ADJACENT_TO_INDUSTRIAL_ZONE');
In table RequirementSets you are calling it 'PLOT_ADJACENT_TO_INDUSTRIAL_ZONE_FARM_REQUIREMENTS', whereas in table RequirementSetRequirements you are calling it 'PLOT_ADJACENT_TO_INDUSTIRAL_ZONE_FARM_REQUIREMENTS'. Database.log gives an invalid reference error stating the following
Code:
[1595298.506] [Gameplay] ERROR: Invalid Reference on RequirementSetRequirements.RequirementSetId - "PLOT_ADJACENT_TO_INDUSTIRAL_ZONE_FARM_REQUIREMENTS" does not exist in RequirementSets
This error message is completely accurate because these are not the same thing:
_TO_INDUSTRIAL_ZONE_
_TO_INDUSTIRAL_ZONE_
Learn to use and trust Database.log -- it will lead you to what is wrong with your code, though for SQL files the amount of information from any given code error is less than that generally provided for erroneous XML code.

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

And no, I did not see the typo at first either. I had to drop the code into a mod and execute it so that Database.log would tell me what was wrong in order to find the issue.

This is also why we prefer people zip the misbehaving mod as it is from within the game's mods folder and attach or link to a downloadable page so we can execute the code on our end if we cannot spot the error by simply looking at the code.
 
Last edited:
Thank you so much!! I caught that misspelling earlier on a different case and can't believe I both missed this one and did the same mistake spelling it
 
Top Bottom