Essentially.. Arkhan came up with this brillant script which when used with this:
if (cpu_manager:GetActiveModInfo("<mod name>") ~= nil) thenWhere <mod name> is the name on the line in Local.ini (found in DoW's root folder) which tells what active mod is being loaded.
The scripts that drive it are found in utility.ai:
function Util_GetIniSetting(sFile, sVal, sDef) local ini = nil ini = io.open(sFile, "r") if(ini ~= nil) then for line in ini:lines() do for k, v in string.gfind(line, "(%w+)=(.+)") do if(k == sVal) then return v end end end end return sDef end function GetActiveDowMod() return Util_GetIniSetting("Local.ini", "currentmod", "w40k") end function GetActiveWxpMod() return Util_GetIniSetting("Local.ini", "currentmodwa", "wxp") end function ModIsActive(module_file, iswa) if(iswa == true) then if(string.lower(GetActiveWxpMod()) == string.lower(module_file)) then return true else return false end else if(string.lower(GetActiveDowMod()) == string.lower(module_file)) then return true else return false end end end function ModIsPresent(module_file, iswa) local file_id = nil file_id = pcall(io.open, module_file .. ".module", "r") if (file_id ~= nil) then file_id:close() return true else return false end endThis work great and now when mod is active the AI can check if it exists then run any mod-specific code we wish..
Now.. the new challenge..
Whats going to happen is in order to incorporate multiple mods at once the above scripts DO NOT take into account many mods being used at once.. it only checks in Local.ini for an active mod but not then that mod's .module file for such things as..
RequiredMod.3 = steel_legion RequiredMod.4 = harlequins RequiredMod.5 = tyranids RequiredMod.6 = Tau_ModFrom RequiredMod.3 to, say, 99 should be checked and then acknowledged as being active as well similar to the main mod detection. Is this possible?
A new script would look like this before running custom mod scripts:
if (cpu_manager:GetRequiredModInfo("<mod name>") ~= nil) then
Thanks all! Input is INCREDIBLY valuable!