Need some fresh eyes...or maybe a brain

Chad Darden

Chieftain
Joined
Dec 30, 2017
Messages
8
Can someone please look at this and tell me what's wrong, cuz I'm at a loss. Am I crazy or is it right there in traits with no syntax error?

[2943265.934] [Gameplay] ERROR: near "INSERT": syntax error
[2943265.935] [Gameplay] ERROR: FOREIGN KEY constraint failed
[2943265.935] [Gameplay] ERROR: FOREIGN KEY constraint failed
[2943265.935] [Gameplay]: Validating Foreign Key Constraints...
[2943265.936] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_CLD_ALAMO" does not exist in Traits
[2943265.948] [Gameplay]: Failed Validation.

Code:
<Row BuildingType="BUILDING_CLD_ALAMO" Name="LOC_BUILDING_CLD_ALAMO_NAME" Description="LOC_BUILDING_CLD_ALAMO_DESCRIPTION" PrereqTech="TECH_MILITARY_ENGINEERING" PrereqDistrict="DISTRICT_ENCAMPMENT" PurchaseYield="YIELD_GOLD" Cost="195" AdvisorType="ADVISOR_CONQUEST" Maintenance="0" CitizenSlots="1" TraitType="TRAIT_CIVILIZATION_BUILDING_CLD_ALAMO"/>

Code:
INSERT INTO Types
        (Type,                                                    Kind)
VALUES    ('TRAIT_CIVILIZATION_CLD_DONT',                            'KIND_TRAIT'),
        ('TRAIT_CIVILIZATION_BUILDING_CLD_ALAMO',                'KIND_TRAIT');
--------------------------------------------------------------------------------------------------------------------------           
-- Traits           
--------------------------------------------------------------------------------------------------------------------------               
INSERT INTO Traits               
        (TraitType,                                                    Name,                                                Description)
VALUES    ('TRAIT_CIVILIZATION_CLD_DONT',                            'LOC_TRAIT_CIVILIZATION_CLD_DONT_NAME',                    'LOC_TRAIT_CIVILIZATION_CLD_DONT_DESCRIPTION'),
        ('TRAIT_CIVILIZATION_BUILDING_CLD_ALAMO',                'LOC_TRAIT_CIVILIZATION_BUILDING_CLD_ALAMO_NAME',        'LOC_TRAIT_CIVILIZATION_BUILDING_CLD_ALAMO_DESCRIPTION');
 
It seems there's an error with you Buildings code. You've put 'TraitType' in the Building code.

What you need to do is use BuildingModifiers (BuildingType, ModifierId).... I think.

Have a look at the code for buildings of Civilizations, and use them as a guide.

Also, my suggestion is to use one type of code. You've used XML in one, and SQL in another. I would use SQL instead, as it's more flexible than XML.
 
It seems there's an error with you Buildings code. You've put 'TraitType' in the Building code.

What you need to do is use BuildingModifiers (BuildingType, ModifierId).... I think.
TraitType is a valid column in table Buildings.
Code:
<Row BuildingType="BUILDING_STAVE_CHURCH" Name="LOC_BUILDING_STAVE_CHURCH_NAME"
Description="LOC_BUILDING_STAVE_CHURCH_DESCRIPTION" PrereqCivic="CIVIC_THEOLOGY"
PrereqDistrict="DISTRICT_HOLY_SITE" PurchaseYield="YIELD_GOLD"
Cost="120" AdvisorType="ADVISOR_RELIGIOUS" Maintenance="2"
CitizenSlots="1" TraitType="TRAIT_CIVILIZATION_BUILDING_STAVE_CHURCH"/>
--------------------------------------------------------------------------------------

The issue is a syntax error in the SQL file where the Trait is defined. The entire file would be needed in order to spot the error because as it is I cannot see it.

Do note however that you will also sometimes get "syntax" errors for errors in filenames of the mod or for errors related to action names in the modinfo file of the mod. These are file loading errors but they sometimes show as syntax errors in database.log

You need to inspect modding.log and ensure that the SQL file is even being loaded at all, and if it is then you need to look upfile from the code you've posted for the syntax error if the game appears to be attempting to load the file.
 
Code:
[2998898.540] Status: Creating database save point.
[2998898.540] Status: UpdateDatabase - Loading Core/CLD_Buildings.xml
[2998898.541] Status: UpdateDatabase - Loading Core/CLD_Leaders.xml
[2998898.542] Status: UpdateDatabase - Loading Core/Joshs_Template_GameDefines.sql
[2998898.542] Warning: UpdateDatabase - Error Loading SQL.
[2998898.542] ERROR: Failed to release save point.
[2998898.555] Warning: Error when calling IComponentHandler::ApplyComponent.
[2998898.555] Status: Applying Component - NewAction (UpdateText)
[2998898.556] Status: Creating database save point.

It is trying to load, so I need to look in buildings.xml or leaders.xml which it loaded first or do you mean in the same file as the code I posted?
 
is that from your database.log?

Looks like you have 2 XMLs and 1 SQL, and the error states error loading SQL, so I would think the error is in Joshs_Template SQL somewhere.
 
Well, not sure what exactly did it but its working now. I think it may have been a duplicate entry for the Rough Rider as Civ trait and Leader trait. Thanks for the help guys. Now to test it and make sure the traits actually work.
 
Back
Top Bottom