Home   Help Search Login Register  

Author Topic: variable variable names  (Read 2412 times)

0 Members and 1 Guest are viewing this topic.

Offline tcp

  • Members
  • *
    • Violator Gaming
variable variable names
« 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?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: variable variable names
« Reply #1 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;

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: variable variable names
« Reply #2 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?
« Last Edit: 29 Aug 2009, 16:37:01 by tcp »