Werthles 52 Posted May 9, 2020 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
phronk 895 Posted May 10, 2020 _myBigboiScript = execVM "myBigBoiScript.sqf"; waitUntil {scriptDone _myBigboiScript}; //waits for _myBigboiScript to finish before proceeding//Rest of the code 1 1 1 Share this post Link to post Share on other sites
pierremgi 4736 Posted May 10, 2020 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. 1 1 Share this post Link to post Share on other sites
gc8 970 Posted May 10, 2020 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 }]; 1 1 Share this post Link to post Share on other sites
Werthles 52 Posted May 11, 2020 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. 1 Share this post Link to post Share on other sites