Jump to content
Sign in to follow this  
charon productions

Variable reference for unnamed unit

Recommended Posts

Search has yielded a few old topics and the suggestions made there don`t work for me.

My problem:

I have unnamed units that i have to leave unnamed

I write the string of the unit`s variable into a listbox

lbSetData [204, _index, format ["%1",_gr select _i]];

I read the listbox out

lbData [204, _i]

Convert the string to code

and want to get a pointer to that unit again.

_unit =

IF i used arrays there would be an unpleasant lag, because there is hundreds of elements in the arrays already.

I have tried :

call compile format ["_unit = %1", lbData [204, _i]];

which should work but it doesn`t. _unit stays empty.

Also if i use unit as (global variable) without underscore.

I guess the problem is that the engine does not

accept a command line like : _unit = 0 1-1-3W;

Is there any workaround someone can think of other than arrays to get a pointer to that unit again?

Has anyone succesfully done something similar?

Share this post


Link to post
Share on other sites

It would be an enormous effort to re-organize/re-write many scripts that i already have that add units to the listboxes and give names to them at these points.

The appilcation that i write is just to monitor troops, i don`t wanna interfere with mission makers naming preferences.

I kind of like these generic names in a way too.

Share this post


Link to post
Share on other sites

Okay now i have named all unnamed units by script command setvehiclevarname , but still cant get

a pointer from the listbox string to the actual unit that would have the type object.

I got the error that it is a string or sometimes a number and not an object, i used :

call compile format ["_unit = %1;", lbData [204, _i]];

and this is how i named the unnamed units (i name them with themselves, just to get them named):

_VarName=format ["%1",_x];

_x setVehicleVarName _VarName;

_x Call Compile "_VarName=_This ;";

I don`t get any errors when i name units in the Editor regularly, but using setvehiclevarname

creates problems.

Can anyone help me?

Edited by Charon Productions

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  

×