Detecting Other Mods through SQL

InkAxis

King
Joined
Feb 24, 2020
Messages
779
So I wanted to make a mod I made compatible with another mod, specifically the Enlightenment Era for VP mod. The mod I am making uses VP.
Code:
INSERT INTO COMMUNITY   
        (Type,             Value)
VALUES  ('MonopolyBuilds', 2);

UPDATE COMMUNITY
SET Value = '1'
WHERE Type = 'MonopolyBuilds' AND EXISTS (SELECT * FROM Buildings WHERE Type='BUILDING_EE_BASTION') AND NOT EXISTS (SELECT * FROM COMMUNITY WHERE Type='MonopolyBuilds' AND Value= 0);

UPDATE Buildings SET PrereqTech = 'TECH_EE_ROMANTICISM' WHERE Type = 'BUILDING_IA_PERFUME_SHOP' AND EXISTS (SELECT * FROM COMMUNITY WHERE Type='MonopolyBuilds' AND Value= 1);

I took this code from another mod for VP, and modified it for my buildings. In the code above, I'm just changing a building to have a different tech unlock.

So first it makes the table with the Value of 2. You can set it to different values: 0=Never activate, 1=Always activate, 2=Activate if it detects the mod.
Next part it sets the value to 1 if it finds BUILDING_EE_BASTION (a building added by the mod I'm trying to detect) and if Value isn't 0.
Last part just changes the building if the Value is 1.

When I set the Value to 1 at the beginning, it works, but just that it will always try to change the prereq tech, and I want it to only change if it detects the mod. So I suspect the issue is with the second part, where it detects the mod? Or am I misunderstanding something?
 
"Or am I misunderstanding something?" - Probably load order.

You will need to make your mod depend on a) the mod that adds the COMMUNITY database table AND b) reference the mod you are trying to detect
 
Top Bottom