Detecting the (a) DLL

Hambil

Emperor
Joined
Oct 16, 2006
Messages
1,100
I thought this had come up before. I swear I remember a lengthy discussion on detecting if a mod is installed. But I can't find it.

So if this is a repeat forgive me. That is what happens when you take like two years off. :)

So the question then is how, in game (after all mods have loaded) do I detect if a specific mod/dll is loaded?
 
I'm off to run some tests but it looks like I can grab a table of mods via
Code:
local unsortedInstalledMods = Modding.GetModBrowserInstalledListings();
Then cruise it for the right mod name.
Code:
local installed = false
for mod in unsortedInstalledMods do
    if somemod:Name == "somemod"  and somemod:Enabled is true then installed = true end
end
Looks like you can also check version # if needed. However, if the mod id doesn't change it might be more stable than the name. I am not sure if changing the name is considered an edit or a new mod by steam and if the mod id would change.
 
IIRC GetModBrowserInstalledListings() returns which mods are installed, not those installed and activated. You need to use GetActivatedMods(), for example

Code:
local isUsingIGE = false

local IGEModId = "170c8ed1-b516-4fe2-b571-befeac39d220"
for _, mod in pairs(Modding.GetActivatedMods()) do
  if (mod.ID == IGEModId) then
    isUsingIGE = true
    break
  end
end

Oh yes, and check for the GUID, not the name (as that may be changed by a mod author without the system considering that the mod is different).

If you're just after a DLL and you know that it adds a unique method on the Game (or Map) object, you can just check for that method existing, eg

Code:
local isUsingVMC = (Game.GetCustomModOption ~= nil)

(Does assume that no one else has implemented such a method in their DLL)
 
Back
Top Bottom