OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: tcp on 29 Aug 2009, 05:06:13

Title: variable variable names
Post by: tcp on 29 Aug 2009, 05:06:13
Is it possible to use a integer to call a variable name such as IED1tr, IED2tr, etc. so that when _num=2 something like ("IED"_num"tr") could be interpreted as a variable name instead of a string?
Title: Re: variable variable names
Post by: Mandoble on 29 Aug 2009, 09:38:23
Code: [Select]
_left_Ve_1 = 0;

// Following executes _left_ve_1=2
call compile format["_left_ve_%1=%2", 1, 2];

hint str _left_ve_1;
Title: Re: variable variable names
Post by: tcp on 29 Aug 2009, 16:26:08
Thank you. I needed a trigger activated variable to be random so my script could be ran on different objects. This should work. However, how would I get the unique ID on the object (vehicle) that executed the script if I already passed this through the init line?