Jump to content

Check if a mod is activated through modmain


kiopho

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
Link to comment
Share on other sites

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:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...