FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login
    The current pre-release of the client ("pioneer" in the version) is only compatible to itself. So you can only play with other testers. Please be aware!

    Check for Specific Mods Loaded

    Scheduled Pinned Locked Moved Modding & Tools
    4 Posts 4 Posters 382 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      Rama
      last edited by

      Is there a function or script to check to see if certain mods are enabled? Like if I wanted to detect a specific unit pack mod is in use?

      M 1 Reply Last reply Reply Quote 0
      • M Offline
        Mavr390 @Rama
        last edited by

        @rama Quite a long time ago I found (in one of the mods) a modlocator.

        local MODfound = 'nottrue'
        
        function MODisactive()
        	if MODfound == 'nottrue' then
        		MODfound = GetActiveModLocation("Your mod ID")
        	end
        	return MODfound
        end
        
        function GetActiveModLocation( mod_Id )
            for i, mod in __active_mods do
        	if  mod_Id == mod.uid then
        	    LOG("MANIMAL\'s MOD LOCATOR INFO:  Active Mod Found (name="..(mod.name or 'unknown')..", UID="..(mod.uid or 'none')..", location = "..mod.location..")  .")
        	    return mod.location
            	end
            end
            return nil
        end
        

        I always keep this file in the root folder of the mod.
        It gives variety. If the mod is enabled, then one action occurs, and if it is disabled, then another.
        In *script.lua it looks like this:

        local MODISACTIVE = import('/mods/Your mod name/modlocator.lua').MODisactive()
        
            OnStopBeingBuilt = function(self,builder,layer)
        	if MODISACTIVE then
        
        	else
        
        	end
        	Unit.OnStopBeingBuilt(self,builder,layer)
            end,
        

        Try. This modlocator helps me out.

        1 Reply Last reply Reply Quote 1
        • FichomF Offline
          Fichom
          last edited by

          If you are working on say your own mod, there is a way. I'm not 100% on what it is, but 4z0t's ScoreBoard has a mod dependency (requires UI Mod Tools V8) , so you can probably check how he did that and derive your own functions.

          1 Reply Last reply Reply Quote 1
          • C Offline
            CDRMV
            last edited by CDRMV

            I have uses this in my Commander Survival Kit to Check If one of my Mods is activated.
            The Check is required for the Space Reinforcements Manager, which should be only available If a Player has activate my Space Mod (FBP Orbital). If Not the Space Reinforcements Manager is simple Not available for the Player If He plays the Commander Survival Kit Ingame.

            local GetFBPOPath = function() for i, mod in __active_mods do if mod.name == "(F.B.P.) Future Battlefield Pack: Orbital" then return mod.location end end end
            FBPOPath = GetFBPOPath()

            In other Files in CSK
            I Just use this Code to Check it:

            If FBPOPath then
            --Load Content or Functions
            else
            -- Empty = Do nothing
            end

            Really simple and easy

            This Code is located in /Mods/Commander Survival Kit/hook/Lua/Game.lua and appears in other Lua Files of CSK as Well. It works perfectly

            1 Reply Last reply Reply Quote 1
            • First post
              Last post