Jump to content
BlacKnightBK

undefined variable error that has been defined

Recommended Posts

Hela boys, so I wrote a small script that creates a trigger and allows CSAT units withing this trigger to communicate with each other and switch their mode to aware if they spot an NME.

The problem i am having is every time i test it tells me the variable _allUnits is undefined which doesn't make sense to me. Plz help

/*-----------------------------------------------------------------
 File Name: DAI_Behaviour.sqf
 Created by: Y. Ibrahim
 Community: Arma Team Play
 TS: ateamplay.clants.nl

 Use, distribution and editing of this file is authorized as long
 as the credits above are left untouched. However, if you would like
 to use multiple files wriiten by this author you are required to get
 author's permission.

 This script was given to me by Igneous01 on the Bi forums but i did
 major editing to it so it would meet my needs.
-------------------------------------------------------------------*/

private ["_allUnits","_aoTrigger"];

_aoTrigger = createTrigger ["EmptyDetector", getMarkerPos MAINAOLOC];
_aoTrigger setTriggerArea [2000, 2000, 0, false];
_aoTrigger setTriggerActivation ["EAST", "PRESENT", false];
_aoTrigger setTriggerStatements ["this","",""];

_allUnits = [];
_allUnits = (list _aoTrigger);
while {true} do {

	{
		private _unit = _x;
		{
			private _entity = _x;
			if (_unit knowsAbout _entity > 0.1) then {
				if ((side _entity) isEqualTo west) then {
					{_x reveal [_entity,(_unit knowsAbout _entity)]} foreach _allUnits;
					{
						private _squad = group _x;
						_squad setBehaviour "aware";
					}foreach _allUnits;
				};
			};
		}foreach _unit nearTargets 1000;
	}foreach _allUnits;


	sleep 200;
};

 

Share this post


Link to post
Share on other sites

Can you send the full error log ?  Cause indeed _allUnits should be defined according to this

_allUnits = (list _aoTrigger);

might be the culprit where this sends back undefined, put diag_logs behind every line where you manipulate _allUnits

Share this post


Link to post
Share on other sites
1 minute ago, celludriel said:

Can you sent the full error log ?  Cause indeed _allUnits should be defined according to this

}foreach |#|_allunits;

sleep 200;
};
Error Undefined variable in expression: _allunits

 

Share this post


Link to post
Share on other sites
_allUnits = (list _aoTrigger);
diag_log format ["_allUnits %1", _allUnits];

What output does this give you ?  You are sure _allUnits is filled up here

Share this post


Link to post
Share on other sites
34 minutes ago, celludriel said:

_allUnits = (list _aoTrigger);
diag_log format ["_allUnits %1", _allUnits];

What output does this give you ?  You are sure _allUnits is filled up here

 
 
 

Thank you, apparently it wasn't getting filled up since this loops starts before the AIs were getting spawning, I added a sleep command before it fills the array and now it finally goes through the loop

  • 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

×