Does Anyone Know Assyria's Code Designation?

MEQ

Chieftain
Joined
Nov 21, 2018
Messages
45
Location
Ireland
I can prevent any civilisation from building specific World Wonders, except Assyria. I think maybe I have their code name wrong. Code I'm using works like so:

Code:
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ASSYRIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AUSTRIA", "BUILDINGCLASS_ALHAMBRA", NULL;

That will prevent Austria from building Alhambra, but not Assyria, and I can't figure out why. Does Assyria not use "CIVILIZATION_ASSYRIA"? There's no other difference between those two lines.

I'll attach my cobbled together mod here in case that helps explain, and so you can see how only Assyria can't be stopped. If anybody can help, please let me know.
 

Attachments

  • CIV Linked World Wonders (v 8).civ5mod
    20.3 KB · Views: 104
First of all, can't reproduce the error. When I load up the mod and play as Assyria, and give myself Chivalry with IGE, I can confirm I can't build Alhambra. Assyria's Type column in the Civilizations table is CIVILIZATION_ASSYRIA, so you have it correct - it all works fine.

Second... egad, man, this SQL can be compressed a lot. Like, A LOT.

This:
Code:
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AMERICA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ARABIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ASSYRIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AUSTRIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AZTEC", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_BABYLON", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_BRAZIL", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_BYZANTIUM", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_CARTHAGE", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_CELTS", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_CHINA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_DENMARK", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_EGYPT", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ENGLAND", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ETHIOPIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_FRANCE", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_GERMANY", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_GREECE", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_HUNS", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_INCA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_INDIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_INDONESIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_IROQUOIS", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_JAPAN", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_KOREA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_MAYA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_MONGOL", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_MOROCCO", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_NETHERLANDS", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_OTTOMAN", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_PERSIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_POLAND", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_POLYNESIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_PORTUGAL", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ROME", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_RUSSIA", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SHOSHONE", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SIAM", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SONGHAI", "BUILDINGCLASS_ALHAMBRA", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SPAIN", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SWEDEN", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_VENICE", "BUILDINGCLASS_ALHAMBRA", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ZULU", "BUILDINGCLASS_ALHAMBRA", NULL;

Can be compressed down to this:

Code:
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType)
SELECT c.Type, "BUILDINGCLASS_ALHAMBRA", NULL
FROM Civilizations c WHERE c.Type != "CIVILIZATION_SPAIN";

Which instantly cuts 43 lines down to 3. And that's only if you want to spread it out on 3 lines instead of 1.

But wait - before you go copying and pasting and editing that code block for every single wonder, we can compress it even more: just do all the insert statements at once.

What I would do is create a table that will just hold a simple mapping of civilization types to buildingclass types:

Code:
CREATE TABLE IF NOT EXISTS Civilizations_WorldWonders(CivilizationType Text REFERENCES Civilizations(Type), BuildingClassType Text REFERENCES BuildingClasses(Type) UNIQUE);

Then add a trigger to basically automate what we did above, the insertion into Civilization_BuildingClassOverrides for everything but the specified civ:

Code:
CREATE TABLE IF NOT EXISTS Civilizations_WorldWonders(CivilizationType Text REFERENCES Civilizations(Type), BuildingClassType Text REFERENCES BuildingClasses(Type) UNIQUE);

CREATE TRIGGER IF NOT EXISTS Civilizations_WorldWonders_OnAdd
AFTER INSERT ON Civilizations_WorldWonders WHEN NEW.CivilizationType IS NOT NULL AND NEW.BuildingClassType IS NOT NULL
BEGIN
    INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType)
    SELECT c.Type, NEW.BuildingClassType, NULL
    FROM Civilizations c WHERE c.Type != NEW.CivilizationType;
END

And then you're set. Just populate the mapping table, and for each row you insert into it, 42 insertions will be made into Civilization_BuildingClassOverrides, without having to copy-paste a separate code snippet for each.

Code:
CREATE TABLE IF NOT EXISTS Civilizations_WorldWonders(CivilizationType Text REFERENCES Civilizations(Type), BuildingClassType Text REFERENCES BuildingClasses(Type) UNIQUE);
CREATE TRIGGER IF NOT EXISTS Civilizations_WorldWonders_OnAdd
AFTER INSERT ON Civilizations_WorldWonders WHEN NEW.CivilizationType IS NOT NULL AND NEW.BuildingClassType IS NOT NULL
BEGIN
    INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType)
    SELECT c.Type, NEW.BuildingClassType, NULL
    FROM Civilizations c WHERE c.Type != NEW.CivilizationType;
END
INSERT INTO Civilizations_WorldWonders
        (CivilizationType,            BuildingClassType)
VALUES    ("CIVILIZATION_SPAIN",        "BUILDINGCLASS_ALHAMBRA"),
        ("CIVILIZATION_SIAM",        "BUILDINGCLASS_ANGKOR_WAT"),
        ("CIVILIZATION_ENGLAND",    "BUILDINGCLASS_BIG_BEN"),
        ("CIVILIZATION_INDONESIA",    "BUILDINGCLASS_BOROBUDUR"),
        ("CIVILIZATION_GERMANY",    "BUILDINGCLASS_BRANDENBURG_GATE"),
        ...

I notice there are some wonders you're allowing for multiple civs, and the particular way I wrote the table and trigger won't work for those, but this has got to shave a couple thousand lines off a 4,443 line script.

But! When I open database.log (from the Assyria playtest), I'm hit with this:

Code:
...
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_SUMMER_PALACE" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_BLETCHLEY_PARK" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_CERN" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_EMPIRE_STATE_BUILDING" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_MOTHERLAND_STATUE" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_SLATER_MILL" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_WTC" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_EE_FASIL_GHEBBI" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_EE_KRONBORG" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_EE_SMITHSONIAN" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_EE_TOPKAPI" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_EE_TORRE" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_EE_VERSAILLES" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_EE_WAT_PHRA_KAEW" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_BARNENEZ" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_GGANTIJA" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_NEWGRANGE" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_SKARABRAE" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_NABAWI" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_ANITKABIR" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_ARECIBO" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_BROOKLYN" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_CHARTRES" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_DAMASCUS" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_GRIPSHOLM" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_HOLLYWOOD" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_ITSUKUSHIMA" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_KARNAK" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_KINKAKUJI" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_MALWIYA" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_MILLAU" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_MICHEL" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_MONTECARLO" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_NAZCA" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_SOVIETS" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_JUMEIRAH" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_PANAMA" does not exist in BuildingClasses
[458689.984] Invalid Reference on Civilization_BuildingClassOverrides.BuildingClassType - "BUILDINGCLASS_ROCKEFELLER" does not exist in BuildingClasses
...

Because you inserted a bunch of custom modded civs and wonders without controlling for the fact that the player probably doesn't have every single one of those prerequisite mods enabled.

So, a workaround. You can amend the mapping table definition to not explicitly reference the Civilizations or BuildingClasses tables, and then amend the trigger to only actually proceed with the insertion into Civilization_BuildingClassOverrides if the strings just coincidentally (wink wink) happen to line up. This should suppress any "invalid reference" errors, which is good if you're not trying to debug, but bad if you are.

Code:
CREATE TABLE IF NOT EXISTS Civilizations_WorldWonders(CivilizationType Text , BuildingClassType Text UNIQUE);
CREATE TRIGGER IF NOT EXISTS Civilizations_WorldWonders_OnAdd
AFTER INSERT ON Civilizations_WorldWonders WHEN NEW.CivilizationType IS NOT NULL AND NEW.BuildingClassType IS NOT NULL
BEGIN
    INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType)
    SELECT c.Type, NEW.BuildingClassType, NULL
    FROM Civilizations c WHERE c.Type != NEW.CivilizationType
    AND EXISTS(SELECT * FROM Civilizations WHERE Type = NEW.CivilizationType)
    AND EXISTS(SELECT * FROM BuildingClasses WHERE Type = NEW.BuildingClassType);
END
INSERT INTO Civilizations_WorldWonders
        (CivilizationType,            BuildingClassType)
VALUES    ("CIVILIZATION_SPAIN",        "BUILDINGCLASS_ALHAMBRA"),
        ("CIVILIZATION_SIAM",        "BUILDINGCLASS_ANGKOR_WAT"),
        ("CIVILIZATION_ENGLAND",    "BUILDINGCLASS_BIG_BEN"),
        ("CIVILIZATION_INDONESIA",    "BUILDINGCLASS_BOROBUDUR"),
        ("CIVILIZATION_GERMANY",    "BUILDINGCLASS_BRANDENBURG_GATE"),
        ...

Again, note that wonders available to multiple civs would need to be dealt with separately. But this still eliminates several thousand lines.
 
Personally I would have done it primarily via lua and an SQL "White List" table (and not bothered with Civilization_BuildingClassOverrides) but that's just me I guess. It would have the advantage of not generating errors or bugginess in the case where a player may or may not have a given other mod (or set of mods) enabled, and simplifies thereby the "special case" issues.

And these types of SQL chunks will generally fail because the Language tables are inserted in a seperated database from the normal gameplay database and the two databases cannot directly communicate with one another nor pull data from each other
Code:
UPDATE Language_en_US
SET Text = "National University"
WHERE Tag = "TXT_KEY_BUILDING_OXFORD_UNIVERSITY"
AND NOT EXISTS (SELECT * FROM BuildingClasses WHERE Type = "BUILDINGCLASS_QANAT");
What is generally required is a new Text-Key that may or may not be used depending on the result of the AND NOT EXISTS clause, and the update is done on table Buildings to redirect BUILDING_OXFORD_UNIVERSITY to use that new TXT_KEY instead of the usual one for the Description column. Like this
Code:
UPDATE Buildings 
SET Strategy = 'TXT_KEY_BUILDING_LRS_SAILMAKER_STRATEGY_EE', Help = 'TXT_KEY_BUILDING_LRS_SAILMAKER_HELP_EE'
WHERE Type = 'BUILDING_LRS_SAILMAKER'
AND EXISTS (SELECT 1 FROM Eras WHERE Type = 'ERA_ENLIGHTENMENT');
So your Update would look something like this
Code:
UPDATE Buildings 
SET Description = 'TXT_KEY_BUILDING_OXFORD_UNIVERSITY_NEW', Civilopedia = 'TXT_KEY_BUILDING_OXFORD_UNIVERSITY_PEDIA_NEW'
WHERE Type = 'BUILDING_OXFORD_UNIVERSITY'
AND NOT EXISTS (SELECT 1 FROM BuildingClasses WHERE Type = "BUILDINGCLASS_QANAT");


Your mod also needs to incude references to other mods which will allow the code-chunk to be properly enacted if your mod and the other mod(s) are both enabled -- the reference causes the other mod to load into the game before your mod when both are being used by the same user
Code:
  <References>
    <Mod id="ce8aa614-7ef7-4a45-a179-5329869e8d6d" minversion="0" maxversion="999" title="The Enlightenment Era" />
    <Mod id="d1b6328c-ff44-4b0d-aad7-c657f83610cd" minversion="0" maxversion="999" title="DLL - Various Mod Components" />
    <Mod id="d9ece224-6cd8-4519-a27a-c417b59cdf35" minversion="0" maxversion="999" title="Future Worlds" />
    <Mod id="ebfd41c6-94ad-47ed-9383-6c9509c4bdfe" minversion="0" maxversion="999" title="Ultimate Eras Mod" />
    <Mod id="8c63c188-045b-4955-bbea-6c685d119c86" minversion="0" maxversion="999" title="Prehistoric Era Reborn" />
  </References>
 
Last edited:
And these types of SQL chunks will generally fail because the Language tables are inserted in a seperated database from the normal gameplay database and the two databases cannot directly communicate with one another nor pull data from each other
I've never tried update queries, but I know for a fact that insert queries into Language_en_US work just fine. In either case I'm not sure how the game engine handles switching between querying the localization DBs vs. the debug DB, but it's impossible to test these kinds of text table queries in an SQLite DB viewer solely because they can't send queries across DBs.
 
I've never tried update queries, but I know for a fact that insert queries into Language_en_US work just fine. In either case I'm not sure how the game engine handles switching between querying the localization DBs vs. the debug DB, but it's impossible to test these kinds of text table queries in an SQLite DB viewer solely because they can't send queries across DBs.
The issue is using an insert or update into one of the language localization tables using Select From conditions pulled from non-localization tables. INSERT INTO, UPDATE, INSERT OR REPLACE INTO all work fine so long as they are direct "set value" types of chunks and not "select value from other table" types of chunks where the other table is not a localization table.

The reverse also tends to fail where a gameplay table chunk is written to attempt to "select" data in one of the Language Localization tables.

An examination of the SQL files here shows some light on the source of these issues:
Code:
C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V\Assets\SQL\
Especially the Civ5DlcLocalizationDatabaseSchema.sql file and its triggers. The tables are created (it appears) in file Civ5LocalizationDatabaseSchema.sql for use in the normal "UpdateDatabase" type of file we are all used to using, and then it appears the data inserted into all these tables are then extracted back out into the LocalizedText table, which appears to then be used to create the necessary language-specific tables within the Localization-Merged.db database.
 
Last edited:
First of all, can't reproduce the error. When I load up the mod and play as Assyria, and give myself Chivalry with IGE, I can confirm I can't build Alhambra. Assyria's Type column in the Civilizations table is CIVILIZATION_ASSYRIA, so you have it correct - it all works fine.
AW Arcaeca, that mod actually works for you? Maybe it just only won't work for me. :( Thank you very much for telling me how I could make that code better. I made every change you suggested. I hope I implemented them correctly.
UPDATE Language_en_US
SET Text = "National University"
WHERE Tag = "TXT_KEY_BUILDING_OXFORD_UNIVERSITY"
AND NOT EXISTS (SELECT * FROM BuildingClasses WHERE Type = "BUILDINGCLASS_QANAT");

So your Update would look something like this

UPDATE Buildings
SET Description = 'TXT_KEY_BUILDING_OXFORD_UNIVERSITY_NEW', Civilopedia = 'TXT_KEY_BUILDING_OXFORD_UNIVERSITY_PEDIA_NEW'
WHERE Type = 'BUILDING_OXFORD_UNIVERSITY'
AND NOT EXISTS (SELECT 1 FROM BuildingClasses WHERE Type = "BUILDINGCLASS_QANAT")
LeeS, thank you so much for helping me. I probably should have warned you that I don't really know anything. I just sort of cobble mods together purely through guessing. Do I just replace that one block of code with your new code for each similar entry? Do I change anything here:
Code:
UPDATE Language_en_US
SET Text = "A National University is the most respected place of education in every civilization.[NEWLINE][NEWLINE]Oxford University, the oldest university in England, and in all of the English speaking world, is a shining example. Founded sometime late in the 11th century, Oxford has been in continuous operation ever since. Famous Oxford graduates include Roger Bacon, William of Ockham, Sir Walter Raleigh, John Donne, Jonathan Swift, Dr. Samuel Johnson, Oscar Wilde, Sir Richard Burton, and J.R.R. Tolkien."
WHERE Tag = "TXT_KEY_BUILDING_OXFORD_UNIVERSITY_PEDIA"
AND NOT EXISTS (SELECT * FROM BuildingClasses WHERE Type = "BUILDINGCLASS_QANAT");
I think I made your References change correctly, but I dunno.
 

Attachments

  • (W) CIV Linked World Wonders (v 9).civ5mod
    4.8 KB · Views: 97
Re read my post more carefully. The code you posted is exactly the sort of thing you should not do because
Code:
UPDATE Language_en_US
will encounter problems with the final line of the code chunk
Code:
AND NOT EXISTS (SELECT * FROM BuildingClasses WHERE Type = "BUILDINGCLASS_QANAT");

You want
Code:
UPDATE Buildings 
SET Description = 'TXT_KEY_BUILDING_OXFORD_UNIVERSITY_NEW', Civilopedia = 'TXT_KEY_BUILDING_OXFORD_UNIVERSITY_PEDIA_NEW'
WHERE Type = 'BUILDING_OXFORD_UNIVERSITY'
AND NOT EXISTS (SELECT 1 FROM BuildingClasses WHERE Type = "BUILDINGCLASS_QANAT");

INSERT INTO Language_en_US (Tag, Text)
VALUES ("TXT_KEY_BUILDING_OXFORD_UNIVERSITY_PEDIA_NEW", "A National University is the most respected place of education in every civilization.[NEWLINE][NEWLINE]Oxford University, the oldest university in England, and in all of the English speaking world, is a shining example. Founded sometime late in the 11th century, Oxford has been in continuous operation ever since. Famous Oxford graduates include Roger Bacon, William of Ockham, Sir Walter Raleigh, John Donne, Jonathan Swift, Dr. Samuel Johnson, Oscar Wilde, Sir Richard Burton, and J.R.R. Tolkien.");

INSERT INTO Language_en_US (Tag, Text)
VALUES ("TXT_KEY_BUILDING_OXFORD_UNIVERSITY_NEW", "National University");
 
Last edited:
UPDATE Buildings
SET Description = 'TXT_KEY_BUILDING_OXFORD_UNIVERSITY_NEW', Civilopedia = 'TXT_KEY_BUILDING_OXFORD_UNIVERSITY_PEDIA_NEW'
WHERE Type = 'BUILDING_OXFORD_UNIVERSITY'
AND NOT EXISTS (SELECT 1 FROM BuildingClasses WHERE Type = "BUILDINGCLASS_QANAT");

INSERT INTO Language_en_US (Tag, Text)
VALUES ("TXT_KEY_BUILDING_OXFORD_UNIVERSITY_PEDIA_NEW", "A National University is the most respected place of education in every civilization.[NEWLINE][NEWLINE]Oxford University, the oldest university in England, and in all of the English speaking world, is a shining example. Founded sometime late in the 11th century, Oxford has been in continuous operation ever since. Famous Oxford graduates include Roger Bacon, William of Ockham, Sir Walter Raleigh, John Donne, Jonathan Swift, Dr. Samuel Johnson, Oscar Wilde, Sir Richard Burton, and J.R.R. Tolkien.");

INSERT INTO Language_en_US (Tag, Text)
VALUES ("TXT_KEY_BUILDING_OXFORD_UNIVERSITY_NEW", "National University");
LeeS, thank you again. I made those changes.
 

Attachments

  • (W) CIV Linked World Wonders (v 10).civ5mod
    4.9 KB · Views: 97
Code:
...
        ("CIVILIZATION_SPAIN",    "BUILDINGCLASS_EE_TORRE"),
        ("CIVILIZATION_SWEDEN",    "BUILDINGCLASS_GRIPSHOLM"),

INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AMERICA", "BUILDINGCLASS_CERN", NULL;
...

Syntax error - there's no semicolon terminating the INSERT statement at the top. I haven't even loaded up the mod and I can already tell database.log is going to have a fit about that and toss the entire file out.

Code:
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AMERICA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ARABIA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ASSYRIA", "BUILDINGCLASS_CERN", NULL;
...

This wasn't... quite what I had in mind when I said wonders available to several civs needed to be dealt with separately. Remember, every 43-line block of code where you're doing this same INSERT INTO statement over and over again can be compressed down by doing all the insertions in a single statement.

Like, this:

Code:
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AMERICA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ARABIA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ASSYRIA", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AUSTRIA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_AZTEC", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_BABYLON", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_BRAZIL", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_BYZANTIUM", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_CARTHAGE", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_CELTS", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_CHINA", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_DENMARK", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_EGYPT", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ENGLAND", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ETHIOPIA", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_FRANCE", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_GERMANY", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_GREECE", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_HUNS", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_INCA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_INDIA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_INDONESIA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_IROQUOIS", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_JAPAN", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_KOREA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_MAYA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_MONGOL", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_MOROCCO", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_NETHERLANDS", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_OTTOMAN", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_PERSIA", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_POLAND", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_POLYNESIA", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_PORTUGAL", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ROME", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_RUSSIA", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SHOSHONE", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SIAM", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SONGHAI", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SPAIN", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_SWEDEN", "BUILDINGCLASS_CERN", NULL;
-- INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_VENICE", "BUILDINGCLASS_CERN", NULL;
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType) SELECT "CIVILIZATION_ZULU", "BUILDINGCLASS_CERN", NULL;

Doesn't do anything different from this:

Code:
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType)
SELECT c.Type, "BUILDINGCLASS_CERN", NULL
FROM Civilizations c WHERE c.Type NOT IN (
    "CIVILIZATION_AUSTRIA",
    "CIVILIZATION_DENMARK",
    "CIVILIZATION_ENGLAND",
    "CIVILIZATION_FRANCE",
    "CIVILIZATION_GERMANY",
    "CIVILIZATION_GREECE",
    "CIVILIZATION_NETHERLANDS",
    "CIVILIZATION_POLAND",
    "CIVILIZATION_PORTUGAL",
    "CIVILIZATION_ROME",
    "CIVILIZATION_SPAIN",
    "CIVILIZATION_SWEDEN",
    "CIVILIZATION_VENICE"
) AND EXISTS(SELECT * FROM BuildingClasses WHERE Type = "BUILDINGCLASS_CERN");

except for being harder to read. (And I should stress that SQLite doesn't much care where you add line breaks; I've added them here for clarity, but you could compress it all onto one line if you wanted)

I've been trying to think if there's any way to avoid having to deal separately with wonders available to multiple civs, but I don't think there is. You'd essentially have to loop through the civ-to-wonder mapping table after all insertions have been made and, for each wonder, make a temporary list that holds all the civilizations mapped to it, and then do the Civilization_BuildingClassOverrides insertion for all civs not in that list. The problem is that "after all insertions have been made" part, which AFAIK SQLite has no way of detecting.
 
Code:
        ("CIVILIZATION_SWEDEN",    "BUILDINGCLASS_GRIPSHOLM");
Oh! You mean a semicolon goes at the end there?
Code:
INSERT INTO Civilization_BuildingClassOverrides (CivilizationType, BuildingClassType, BuildingType)
SELECT c.Type, "BUILDINGCLASS_CERN", NULL
FROM Civilizations c WHERE c.Type NOT IN (
    "CIVILIZATION_AUSTRIA",
    "CIVILIZATION_DENMARK",
    "CIVILIZATION_ENGLAND",
    "CIVILIZATION_FRANCE",
    "CIVILIZATION_GERMANY",
    "CIVILIZATION_GREECE",
    "CIVILIZATION_NETHERLANDS",
    "CIVILIZATION_POLAND",
    "CIVILIZATION_PORTUGAL",
    "CIVILIZATION_ROME",
    "CIVILIZATION_SPAIN",
    "CIVILIZATION_SWEDEN",
    "CIVILIZATION_VENICE"
) AND EXISTS(SELECT * FROM BuildingClasses WHERE Type = "BUILDINGCLASS_CERN");
Thank you very much for that code! So that's actually all just one line, but spaces can be added anywhere. I like those line breaks.

I made those changes.
 

Attachments

  • (W) CIV Linked World Wonders (v 11).civ5mod
    4.3 KB · Views: 83
Top Bottom