Jump to content
Sign in to follow this  
spitfire007

Problem with while do loop

Recommended Posts

I can't see why this is not passing the _selectedBuilding out once the position is not less than 1000.

_posSelectedBuilding passes fine when the first value of the array is over 1000 but _selectedBuilding = any

?? going blind and tired ..


_posSelectedBuilding =0;

while {_posSelectedBuilding < 1000} do {

_selectedBuilding = _buildingsArray call BIS_fnc_selectRandom;	
_posSelectedBuilding = getPosASL _selectedBuilding;
_posSelectedBuilding = _posSelectedBuilding select 0; 
};

diag_log format ["#################### _posSelectedBuilding in _posSelectedBuilding = %1", _posSelectedBuilding];
diag_log format ["#################### _selectedBuilding in _selectedBuilding = %1", _selectedBuilding];

Share this post


Link to post
Share on other sites

What is the script supposed to do?

Share this post


Link to post
Share on other sites

Try intially declaring "_posSelectedBuilding" as an empty array instead of an integer:

_posSelectedBuilding = [];

Share this post


Link to post
Share on other sites
Try intially declaring "_posSelectedBuilding" as an empty array instead of an integer:

_posSelectedBuilding = [];

yes, the position is an array

Share this post


Link to post
Share on other sites

_selectedBuilding is showing up as "any" because you haven't declared it outside of the while loop's scope; thus, the variable is meaningless outside of the loop. Put "_selectedBuilding = objNull;" right below your first line (before the while loop) to solve this problem. See also: http://community.bistudio.com/wiki/Variables#Scope

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  

×