API:Optional dependencies in WAR

From TheWarWiki

Jump to: navigation, search

There's not a simple "optional dependencies" field in the .mod file, but there is a workaround that you can place in your addon's OnInitialize handler:

local mods = ModulesGetData()
for k,v in ipairs(mods) do
    if v.name == "NameOfOptDepMod" then
        if v.isEnabled and not v.isLoaded then
            ModuleInitialize(v.name);
        end
        break
    end
end

If you wanted to use this for multiple optdep mods, you would probably want to remove the break statement so that multiple entries could be matched; it's placed there only for efficiency when matching a single name only.

Personal tools