Jump to content
Werthles

Script/Function Priority

Recommended Posts

I'd like Arma to prioritise running a large custom function until it completes. Can this be done?

 

I don't think this is possible, but thought I should ask!

Share this post


Link to post
Share on other sites

_myBigboiScript = execVM "myBigBoiScript.sqf";

waitUntil {scriptDone _myBigboiScript}; //waits for _myBigboiScript to finish before proceeding

//Rest of the code

  • Like 1
  • Thanks 1
  • Haha 1

Share this post


Link to post
Share on other sites

Depending on the context. Some scripts seem to be broken in an heavy scenario, running multiple scripts or even multiple fsm due to too many units.

So, some scripts running fair on test in simple mission can fail on heavy scenario, inconsistently, just because the scheduler is overloaded.

I experienced that for my respawn vehicles with all the stuff (loadout, skin, crew, waypoints, addActions (like arsenal), pylons, ammos, fuel....) This kind of script can be OK... or never terminated.

One thing which can help (for the result, not the performance), diverting the engine priority, is the use of:

 

isNil {big unscheduled list of commands};

 

See alternative syntax. You can't suspend here, and local variables must be defined correctly. You can spawn or execVm from here, but it's not the aim of such tool.

Heavy script is also a good reason to remember the usage of private/params. Private seems useless most of the time but, in fact, this guarantees your variable will not be overwritten.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
11 hours ago, Werthles said:

I'd like Arma to prioritise running a large custom function until it completes. Can this be done?

 

Yes. One option that I prefer to use is EachFrame event handler. It's very fast environment to run your code but it also runs on every frame. To avoid running at every frame you can either delete the handler when it's done or put some timer in there to run it like every two seconds.

 

example code:

 

 

ehHandle = addMissionEventHandler ["EachFrame", 
{


// Code here



}];

 

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 5/10/2020 at 1:26 AM, phronk said:

_myBigboiScript = execVM "myBigBoiScript.sqf";

waitUntil {scriptDone _myBigboiScript}; //waits for _myBigboiScript to finish before proceeding

//Rest of the code

 

On 5/10/2020 at 10:07 AM, pierremgi said:

Depending on the context. Some scripts seem to be broken in an heavy scenario, running multiple scripts or even multiple fsm due to too many units.

So, some scripts running fair on test in simple mission can fail on heavy scenario, inconsistently, just because the scheduler is overloaded.

I experienced that for my respawn vehicles with all the stuff (loadout, skin, crew, waypoints, addActions (like arsenal), pylons, ammos, fuel....) This kind of script can be OK... or never terminated.

One thing which can help (for the result, not the performance), diverting the engine priority, is the use of:

 

isNil {big unscheduled list of commands};

 

See alternative syntax. You can't suspend here, and local variables must be defined correctly. You can spawn or execVm from here, but it's not the aim of such tool.

Heavy script is also a good reason to remember the usage of private/params. Private seems useless most of the time but, in fact, this guarantees your variable will not be overwritten.

 

On 5/10/2020 at 10:50 AM, gc8 said:

 

Yes. One option that I prefer to use is EachFrame event handler. It's very fast environment to run your code but it also runs on every frame. To avoid running at every frame you can either delete the handler when it's done or put some timer in there to run it like every two seconds.

 

example code:

 

 


ehHandle = addMissionEventHandler ["EachFrame", 
{


// Code here



}];

 

 

 

Thanks all. Very interesting and helpful.

 

I think what I need is the isNil approach. I have a function that can take a minute to complete, but if gameplay is interrupted, no big deal. I have tried it and it appears to work! It seems like very bad practice to paste 1000's of lines of code into this, but this looks like the only way.

  • Like 1

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

×