Jump to content

Recommended Posts

Well the title says it all : I want to know how to check if a mod is active or not. What would be the condition like ?

You can do

if GLOBAL.KnownModIndex:IsModEnabled("somemod") or GLOBAL.KnownModIndex:IsModForceEnabled("somemod") then    print "active!"end
however the "somemod" above is the mod's directory name, so in particular that won't do any good if the mod was installed through the Workshop. I think the best approach is to get the list of all mods which are enabled/force enabled (which is returned as a list of mod directory names), and for each of those check that mod's modinfo for its "human readable name", e.g.

for _, moddir in ipairs( GLOBAL.KnownModIndex:GetModsToLoad() ) do    if GLOBAL.KnownModIndex:GetModInfo(moddir).name == "somemod" then        print "active!"    endend
Edited by simplex

You can do

if GLOBAL.KnownModIndex:IsModEnabled("somemod") or GLOBAL.KnownModIndex:IsModForceEnabled("somemod") then    print "active!"end
however the "somemod" above is the mod's directory name, so in particular that won't do any good if the mod was installed through the Workshop. I think the best approach is to get the list of all mods which are enabled/force enabled (which is returned as a list of mod directory names), and for each of those check that mod's modinfo for its "human readable name", e.g.

for _, moddir in ipairs( GLOBAL.KnownModIndex:GetModsToLoad() ) do    if GLOBAL.KnownModIndex:GetModInfo(moddir).name == "somemod" then        print "active!"    endend

 

Thanks for the quick response buddy, I'll give it a try.

:happypigs:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...