Blitzen88 18 Posted September 27 Im trying to figure out how I can utilize foreach on two different arrays at the same time while filtering the results. I'm trying to apply the targetKnowledge command to all enemy and friendly units: Quote _EnemyUnits = allUnits select { playerside getFriend side _x <= 0.6}; _FriendlyUnits = allUnits select {side _x isEqualto playerside}; { _KnowledgeArray = _x targetKnowledge _EnemyUnits // Here is my issue. I need to check all friendly units against all enemy units //Filter Enemy units that meet certain criteria: _KnownbyGroup = _KnowledgeArray select 0; _KnownbyUnit = _KnowledgeArray select 1; _LastSeen = _KnowledgeArray select 2; if (_KnownbyGroup || _KnownbyUnit && _LastSeen < 30) then { _x (ie enemy unit) pushback _KnownEnemyUnits }; }foreach _Friendly Un Share this post Link to post Share on other sites
Schatten 280 Posted September 29 You need to use nested loops: { _FriendlyUnit = _x; { _KnowledgeArray = _FriendlyUnit targetKnowledge _x; ... } forEach _EnemyUnits; ... } forEach _FriendlyUnits; 1 Share this post Link to post Share on other sites
Blitzen88 18 Posted September 30 17 hours ago, Schatten said: You need to use nested loops: { _FriendlyUnit = _x; { _KnowledgeArray = _FriendlyUnit targetKnowledge _x; ... } forEach _EnemyUnits; ... } forEach _FriendlyUnits; Would this stuff: _KnownbyGroup = _KnowledgeArray select 0; _KnownbyUnit = _KnowledgeArray select 1; _LastSeen = _KnowledgeArray select 2; Go before or after the targetknowledge command? I dint know which bracket/scope it goes in Share this post Link to post Share on other sites
Schatten 280 Posted September 30 Since _KnowledgeArray is returned by targetKnowledge, its elements must obviously be accessed after this array is returned. Share this post Link to post Share on other sites
Blitzen88 18 Posted September 30 15 minutes ago, Schatten said: Since _KnowledgeArray is returned by targetKnowledge, its elements must obviously be accessed after this array is returned. I guess, should it go after } foreach _EnemyUnits or before } foreach _FriendlyUnits? Share this post Link to post Share on other sites
pierremgi 4828 Posted October 1 What is the purpose of your script and what is the ideal data format you'd like to return for that (an array of arrays, a long array of...)? Share this post Link to post Share on other sites
Schatten 280 Posted October 1 14 hours ago, Blitzen88 said: I guess, should it go after } foreach _EnemyUnits or before } foreach _FriendlyUnits? Inside nested forEach, at the same scope. Share this post Link to post Share on other sites
Blitzen88 18 Posted October 2 On 10/1/2024 at 1:32 AM, pierremgi said: What is the purpose of your script and what is the ideal data format you'd like to return for that (an array of arrays, a long array of...)? I was trying to “fix” the Marta Module by creating and removing groupicons based off of targetknowlegde. I think Marta uses Knowsabout. Share this post Link to post Share on other sites