Jump to content
Sign in to follow this  
Grumpy Old Man

dynamic local naming of units from array

Recommended Posts

Hey folks,

absolutely lost and majorly confused here, no clue how to do this.

1.:global array1 has a finite amount of units stored

2.:I need to access each single one of those units and issue them !individual! commands

naming local variables like _unit1,_unit2,etc. seems to be too cumbersome

is there some way to automate this with a foreach loop?

maybe I'm just overcomplicating things, again

Cheers

Share this post


Link to post
Share on other sites

This will generate a number foreach unit which can then be retrieved. Not entirely sure what your plan is so more information would be useful


_n=0;
{
_n=_n+1;
_localName=format["unit%1",_n];
_x setvariable ["name",_localName];

}foreach array1;

Share this post


Link to post
Share on other sites
Not entirely sure what your plan is so more information would be useful

I want to find a way to select a unit from an array, order doesn't really matter, can be ascending or random,

then make it accessible to commands like

unit1 commandfire target1

just as an example

basically I'm looking for a way to make

unit1 = array1 select 0;

into unit1 without having to refer to array1 select 0

but I'm not really sure how

---------- Post added at 16:20 ---------- Previous post was at 15:51 ----------

looks like I found what I wanted

_name = "whatever";
_vehs = nearestObjects [pad1,["2S6M_Tunguska"], 15];

for "_i" from 0 to (count _vehs - 1) do {
(_vehs select _i) setVehicleVarName _name+str(_i);
missionNamespace setVariable [_name + str(_i),( _vehs select _i)];
};

gonna adapt that

Scripting can be one hell of a bad idea if you got no clue what you're doing (like me)

Cheers

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  

×