Jump to content
Sign in to follow this  
Chaos

Adding a unit to array

Recommended Posts

I will add a specified target to array. But i don´t know anymore how to do it.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vehlist = ["T72","BMP2","ZSU"];

_targlist =[];

#loopY

~_wt

~.25 +random .25

_candidate = typeOf (list _trg select _n);

? _candidate in _vehlist : _targlist = (list _targlist) + _candidate;

Only the last line will response me a bug: "type array waiting for object".

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_targlist = _targlist + _candidate doesn´t works too.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_targlist = _targlist + [_candidate]

You can only add arrays, so you have "convert" the object to an array before adding.

Share this post


Link to post
Share on other sites

Ach, ok - thank you notworthy.gif

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  

×