Jump to content
Sign in to follow this  
scottb613

Test - waituntil all units are loaded into cargo ?

Recommended Posts

Hi Folks,

 

Normally I can find something to help me get through each task I need to complete - although it might not be the most efficient method... I'm struggling a bit with this one...

 

I have an array of infantry group names - I want to "waitUntil" all infantry units are loaded into cargo...

 

This is where I'm at - the example below doesn't work - just illustrates my thought process...

 

Any suggestions or help appreciated...

 

{
	_vehicle = slick1;
	_infGroup = missionNamespace getVariable [_x, objNull];
	_infUnitArr = units _infGroup;
	{
		_cargoIndex = _vehicle getCargoIndex _x;
		waitUntil { _cargoIndex != -1 }; 
	} foreach _infUnitArr; 
} foreach _infGroupArr;

 

Thanks...

 

Regards,
Scott

 

Share this post


Link to post
Share on other sites
waituntill { sleep 1; ( {alive _x && !(_x in yourHelicopterName)} count ( (units yourGroupName1) + (units yourGroupName2) ) == 0 };

 

  • Like 1

Share this post


Link to post
Share on other sites
23 minutes ago, M1ke_SK said:

waituntill { sleep 1; ( {alive _x && !(_x in yourHelicopterName)} count ( (units yourGroupName1) + (units yourGroupName2) ) == 0 };

 

 

Hi...

 

Sorry - one follow up -the first open paren is a typo right - there is no matching close paren...

 

Regards,
Scott 

Share this post


Link to post
Share on other sites

Yeah, I am missing last bracket there, but you got raw idea how to do it now.

 

waituntill { sleep 1; ( {alive _x && !(_x in yourHelicopterName)} count ( (units yourGroupName1) + (units yourGroupName2) ) ) == 0 };

 

  • Like 1

Share this post


Link to post
Share on other sites

LOL - I caught that myself...

:f:

 

The number of groups per helicopter can vary... Possible (4) helicopters with possible (4) infantry groups per helicopter... Just wanted to insure everyone was loaded prior to commencing with engine start... I tried starting the engines before the chalks completed loading - but I couldn't hold them on the ground - they just popped up an hovered like 20 meters off the ground - even with flyinHeight set to 0...

 

My implementation (I can't test until weekend):

 

// (CHALK) waituntil each chalk loaded as cargo //
{
	_slkUnt = slick1;
	_chkGrp = missionNamespace getVariable [_x, objNull];
	waituntil { sleep 2; ({alive _x && !(_x in _slkUnt)} count (units _chkGrp)) == 0 };
	
} foreach _chk1Arr;

{
	_slkUnt = slick2;
	_chkGrp = missionNamespace getVariable [_x, objNull];
	waituntil { sleep 2; ({alive _x && !(_x in _slkUnt)} count (units _chkGrp)) == 0 };
	
} foreach _chk2Arr;

{
	_slkUnt = slick3;
	_chkGrp = missionNamespace getVariable [_x, objNull];
	waituntil { sleep 2; ({alive _x && !(_x in _slkUnt)} count (units _chkGrp)) == 0 };
	
} foreach _chk3Arr;

{
	_slkUnt = slick4;
	_chkGrp = missionNamespace getVariable [_x, objNull];
	waituntil { sleep 2; ({alive _x && !(_x in _slkUnt)} count (units _chkGrp)) == 0 };
	
} foreach _chk4Arr;

 

Regards,

Scott

 

 

Share this post


Link to post
Share on other sites

Hi Folks,

 

Obviously we need ( 0 == 0 ) to continue from the [waitUntil] loop...

 

I was confused on how you were making the "unit is alive" and "unit is not in Helicopter" a condition of [count]... Up until now I thought [count] only had one parameter - the array you were counting...

 

As usual - wiki - has the answer and shows the alternative syntax which applies here and adds a "condition" to the mix:

 

[Count]

Syntax: condition count array

Parameters: condition: Code that must return true for the tested element to be counted. 

The variable _x will contain the currently tested element. 

array: Array

Return Value: Number

 

Regards,

Scott

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
Sign in to follow this  

×