Jump to content

Recommended Posts

I want to make a trigger which execVM an sqf file and wait until it finishes. But every time it gives me an error or it doesn't wait at all.

 

I tried:

myhandle = [] execVM "test.sqf";

waitUntil { scriptDone myhandle };

and it gave me this: waitUntil { |#|scriptDone my.. Generic error in expression

 

also tried:

myhandle = [] execVM "test.sqf";

null = [] spawn { waitUntil { scriptDone myhandle }};

then it does not wait at all. The trigger activates before the sqf finish.

 

Inside the sqf, there is a variable at the end: test_sqf_running = nil

I also tried: 

[] execVM "test.sqf";

waitUntil { sleep 1; isNil "test_sqf_running" };

and this happened: waitUntil { |#|sleep 1; is... Generic error in expression.

 

also tried with spawn and it activates before the sql finish.

 

Where is it wrong?

Share this post


Link to post
Share on other sites

Try this.

[] spawn {
  call compile preProcessFile "test.sqf";
  
  // Any code to be executed after test.sqf has finished.
};

 

Share this post


Link to post
Share on other sites
29 minutes ago, tr3b said:

myhandle = [] execVM "test.sqf"; 
waitUntil { scriptDone myhandle };

 

In this instance you have an unscheduled environment which means you can't use sleep or waitUnitl commands. You have to spawn a script first.

 

31 minutes ago, tr3b said:

myhandle = [] execVM "test.sqf"; 
null = [] spawn { waitUntil { scriptDone myhandle }};

 

You are better off putting all the commands in the spawn part: (solution for your problem)

null = [] spawn { 
	myhandle = [] execVM "test.sqf";
	waitUntil { scriptDone myhandle }
};

 

33 minutes ago, tr3b said:

[] execVM "test.sqf"; 
waitUntil { sleep 1; isNil "test_sqf_running" };

 

Again unscheduled environment. Also the waitUntil {sleep 1; ...} only tells the engine to only check the condition once every second instead of once every 0.001 (?) seconds leading to a less resource consuming script.

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, 7erra said:

 Also the waitUntil {sleep 1; ...} only tells the engine to only check the condition once every second instead of once every 0.001 (?) seconds leading to a less resource consuming script.

Yes, and aside this topic, I don't understand why the CBA ACE3 teams definitely avoid this command and prefer some  each framed event handlers, just to stay inside the unscheduled scope.  Not sure to catch the added value.

Share this post


Link to post
Share on other sites

Thanks 7erra and Horner, it works now!

Share this post


Link to post
Share on other sites
9 hours ago, Horner said:

call compile preProcessFile "test.sqf";

Where's the difference to

 #include "test.sqf"

 ?

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

×