Jump to content
WelshyYT

Arma 3 Function Library

Recommended Posts

Hey all I am trying to set up a functions library but for some reason the functions are not executing. Any help will be great, here is my code!
 

class CfgPatches {
    class EODS_Zeus_Module {
        weapons[] = {};
        requiredVersion = 0.1;
        author = "Welshy";
        version = 1.0.0;
        units[] = {"EODS_Module_Base"};
        requiredAddons[] = {"A3_UI_F","A3_UI_F_Curator","A3_Functions_F","A3_Functions_F_Curator","A3_Modules_F","A3_Modules_F_Curator","A3_Modules_F_Bootcamp_Misc"};
    };
};

class CfgFactionClasses
{
    class NO_CATEGORY;
    class EODS_ZEUS : NO_CATEGORY {
        displayName = "EODS Zeus";
    };
};

class CfgFunctions
{
  class EODS
    {
        class Zeus
        {
            //file = "EODS_Zeus\functions";
      class Test{file = "EODS_Zeus\functions\EODS_Zeus.sqf";};
        };
    };
};

class CfgVehicles
{

    class Logic;
    class Module_F : Logic {

        class ArgumentsBaseUnits {
            class Units;
        };

        class ModuleDescription {
            class AnyPlayer;
            class AnyBrain;
            class EmptyDetector;
        };
    };

    class EODS_Module_Base : Module_F
    {
    author = "Welshy";
    displayName  = "Test";
    category = "EODS_ZEUS";
    function = "fnc_Test";
    scope = 1;
    scopeCurator = 2;
        isGlobal = 1;
  };
};

 

Share this post


Link to post
Share on other sites

Here is the function:

fnc_Test =
{
  hint "Test!";
};

 

Share this post


Link to post
Share on other sites
2 hours ago, WelshyYT said:

class CfgFunctions {
	class EODS {            //TAG
		class Zeus {        //Function viewer category
			class Test{     //Function name
				file = "EODS_Zeus\functions\EODS_Zeus.sqf";
			};
		};
	};
};

 

This compiles the function TAG_fnc_className, so EODS_fnc_Test .

 

Your actual file should then just be the code needed for the function.

hint "Test!";

 

  • Like 1

Share this post


Link to post
Share on other sites

Well really you shouldn't, you remove the benefit you get from the functions library of, available in functions viewer and functions automatically compiled final.

Each file should just hold the code need for each function.

 

My usual work flow.

Spoiler

So if you have one file that holds a number of functions...


LARs_fnc_myFirstFunc = {
	//some code
	hint "My first function";
};

LARs_fnc_mySecondFunc = {
	//some code
	hint "My second function";
};

LARs_fnc_myThirdFunc = {
	//some code
	hint "My third function";
};

...you need to separate them out...

Functions library definition...


class CfgFunctions {
	class LARs {
		class someCategory {
			file = "LARs/Functions"; //path relative from mission directory
			class myFirstFunc {};	//file name minus proceding fn_ and .sqf ,see below
			class mySecondFunc {};
			class myThirdFunc {};
		};
	};
};

...where each file would then be...

LARs/Functions/fn_myFirstFunc.sqf  (class name from above proceeded by fn_ )


//some code
hint "My first function";

...would compile the function LARs_fnc_myFirstFunc.

Then do the same for each of the other functions.

 

 

But if you really want to define multiple functions in one file, you can always use the pre/postInit to run the code in the file, in so doing defining all the functions it holds.

Again, I see this as something that goes against the function libraries design, and you do not benefit from the compileFinal the library adds to defined functions.

Spoiler

LARS/Functions/allMyFunctions.sqf


LARs_fnc_myFirstFunc = {
	//some code
	hint "My first function";
};

LARs_fnc_mySecondFunc = {
	//some code
	hint "My second function";
};

LARs_fnc_myThirdFunc = {
	//some code
	hint "My third function";
};

Functions library definition...


class CfgFunctions {
	class LARs {
		class someCategory {
			class allMyFuncs {
				file = "LARs/Functions/allMyFunctions.sqf";
				preInit = 1;
			};
		};
	};
};

Now this will still define a function called LARs_fnc_allMyFuncs, but preInit makes the functions library run the function at preInit. Which in doing so defines all the functions the file holds.

 

  • Like 2

Share this post


Link to post
Share on other sites

@Larrow I plan to use more then one function so you suggest writing one file for each function?

Share this post


Link to post
Share on other sites
6 hours ago, WelshyYT said:

@Larrow I plan to use more then one function so you suggest writing one file for each function?

 

10 hours ago, Larrow said:

...

Each file should just hold the code need for each function.

...

Yes. At least that's what I took away from reading it...

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, WelshyYT said:

so you suggest writing one file for each function?

Yes, something similar to what I showed in the first spoiler of my previous post.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×