Jump to content
magnetar

Order of execution of PreInit functions

Recommended Posts

I am trying to set  some functions at preInit level that have some variables in common. What I would like to know is if there is a possibility to execute functions at PreInit level using a certain order. For example, I have the following (pseudo)-functions in which variables from function B depends on the execution of function A.

fnc_A = {varA = 1; ....};
fnc_B = {if (varA == 1) then { varB == true; };
fnc_C = {if (varB = true) then { ... }};

Is, therefore, a way to define order of execution at PreInit level so that they are executed like:

 

1) fnc_A

2) fnc_B

3) fnc_C

 

and not like

 

1) fnc_B

2) fnc_A

3) fnc_C

 

Thanks in advance!

 

Note: I am aware that by generating a function at preInit that defines the previous three functions would yield the desired results. I am asking however to define such order without having a "master" function.

Share this post


Link to post
Share on other sites

waitUntil the function variable exists:

waitUntil {!isNil "fnc_A"};

Share this post


Link to post
Share on other sites

waitUntil the function variable exists:

 

waitUntil {!isNil "fnc_A"};

Since when waitUntil works in unscheduled environment, that the preInit is?

Share this post


Link to post
Share on other sites

I am trying to set  some functions at preInit level that have some variables in common. What I would like to know is if there is a possibility to execute functions at PreInit level using a certain order. For example, I have the following (pseudo)-functions in which variables from function B depends on the execution of function A.

fnc_A = {varA = 1; ....};
fnc_B = {if (varA == 1) then { varB == true; };
fnc_C = {if (varB = true) then { ... }};

Is, therefore, a way to define order of execution at PreInit level so that they are executed like:

 

1) fnc_A

2) fnc_B

3) fnc_C

 

and not like

 

1) fnc_B

2) fnc_A

3) fnc_C

 

Thanks in advance!

 

Note: I am aware that by generating a function at preInit that defines the previous three functions would yield the desired results. I am asking however to define such order without having a "master" function.

 

Have you tried just defining them in desired order in CfgFunctions? 

Share this post


Link to post
Share on other sites

Have you tried just defining them in desired order in CfgFunctions? 

 

Perhaps OP means the init order of initserver.sqf, initplayerserver.sqf, etc. Even though BI has an init order, the order in which the various files is executed is not always according to BI's init order. Not sure what  causes the variance. 

Share this post


Link to post
Share on other sites

I was working on a totally unrelated problem and I found that if the commands were executed  in the obvious order the whole did not work..

 

By changing the order it all worked just fine.

Share this post


Link to post
Share on other sites
First of all, thanks to all of you for taking time to post!
 

Have you tried just defining them in desired order in CfgFunctions? 

 

I will report on this.  :)

 

Couldn't you just execute them linearly? ;)

 

Aka, function A calls function B calls function C

 

Yes, I was aware of that solution. I was wondering however if one could specify an order somehow... This is the solution I currently have implemented :)

 

Perhaps OP means the init order of initserver.sqf, initplayerserver.sqf, etc. Even though BI has an init order, the order in which the various files is executed is not always according to BI's init order. Not sure what  causes the variance. 

 

No, I was referring to how to "order" preInit functions (which extends to postInit ones as well).

Share this post


Link to post
Share on other sites

Solution: As @killzone_kid pointed out, declaring in description.ext the preInit (and by extension PostInit) functions in the desired order of execution does the trick.

 

@SilentSpike I wonder now if CBA could be eventually extended to handle this. I am not familiar with the code at all but I will try to have a look, as long as this is something the project could benefit from :). I like alphabetical ordering of my functions :D

 

Thanks again to all of you for posting and suggesting solutions.

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

×