Would including the same LUA and SQL file in multiple mods cause a conflict

turingmachine

Emperor
Joined
May 4, 2008
Messages
1,438
What I mean is that Thalassicus and trystero49 made edits to the Civlopedia and City view lua files in order to make dummy buildings used for traits invisible. You also have to update the SQL to alter the tables.

Now say you were making multiple new civs as independent mods, and you include these two edited lua files and the SQL in each mod (the new lua and SQL files are identical in each mod). Would this cause a problem if you then load two of these mods?
 
for the lua file, the most recent will be used, so no problem if they are the same.

for the sql files, it would depend on how they add/change value in the database.

without going in details, if they made an operation on a column (replace A by A+1), instead of having A+1 in the database, you'll have A+N when N is the number of identical SQL file set to update the database...
 
for the lua file, the most recent will be used, so no problem if they are the same.

Only true for VFS=true files (which in the case of replacing core game files they will be) but not generally true for any Lua file
 
for the lua file, the most recent will be used,

which is "most recent" as in "whichever mod the game dll happened to load last"

If you want to check the load order of your mod files, either look in stopwatch.log (obviously!) or place print statements in the lua files
 
for the sql files, it would depend on how they add/change value in the database.

This is the exact SQL file that's used:

Code:
-- Authors: Thalassicus & trystero49

ALTER TABLE Buildings
ADD IsVisible boolean DEFAULT 1;

ALTER TABLE Buildings
ADD PediaVisible boolean DEFAULT 1;

Would that matter if it is loaded a few times through multiple mods?
 
Trying to add the same column twice will cause an error, I'm pretty sure. Perhaps you can make the add conditional. This works for adding tables using:

CREATE TABLE IF NOT EXISTS 'TableName' ...

But I have no idea if this is possible for columns.
 
Trying to add the same column twice will cause an error, I'm pretty sure. Perhaps you can make the add conditional. This works for adding tables using:

CREATE TABLE IF NOT EXISTS 'TableName' ...

But I have no idea if this is possible for columns.

So I would change it to:

ADD IF NOT EXISTS IsVisible boolean DEFAULT 1;

?
 
As I said, I don't know if this works for columns. You can either look it up (google SQLite), try it and see if it works, or hope someone else responds here.
 
So ADD IF NOT EXISTS for the column didn't work.

However, I tried loading three mods that use the same original SQL. It does come up with two errors in the datalog, but the resulting game still works.

I assume it encounters the duplicate SQLs, get's an error, and doesn't load those files, (but it doesn't matter as it did load the first one and it was an identical file). I don't think anything else is affected. All my unit animation SQL loads, as does my XML and LUA.

So, is there any problem playing like this even with the errors (are they doing something I couldn't know about)?
 
Provided the ONLY SQL in the three files is that single line there will be no problem (just the annoyance of an error line or two in the database.log file)

The problems will come if you add any other statements into those files (either before of after that line - it doesn't matter) as those statements will not affect the database - ie the entire file is discarded, not just the single line (or even the line plus any following lines).

This may or may not be what you intended. It does have it's uses - you can use the fact that the G&K database doesn't have a Culture column on the Buildings table to write SQL that will only affect a vanilla database and vice-versa for new G&K columns.

Just make sure if you use these tricks to fully comment the file!

HTH

W
 
Top Bottom