Results 1 to 7 of 7

Thread: Is it possible to have dynamically named variables?

  1. #1

    Is it possible to have dynamically named variables?

    I'm wondering if it is possible to have a variable be named dynamically - and if it's possible, then how is it done?

    I'm thinking of something like
    1_health
    2_health
    3_health
    n_health

    Just a continuation, and have it based off of each player or object.

  2. #2

  3. #3
    missionNamespace setVariable [format ["variable%1", _x], _value];

  4. #4
    how does one refer to a dynamic variable after generating it like this if part of the name was generated from a loop i.e.

    Code:
    _locations = nearestlocations [[0,0,0],["Airport","NameCityCapital","NameCity","NameVillage","NameLocal"],50000];
    
    {
         _locname = name _x;
         _trgname = format ["%1_trigger",_locname];
    
         missionnamespace setvariable [_trgname,createTrigger ["emptyDetector",getpos _x]];
    
    } foreach _locations;
    how would i then go and set the statements for the triggers using settriggerstatements??
    Last edited by zorilya; Sep 17 2012 at 12:10.

  5. #5
    Master Gunnery Sergeant twirly's Avatar
    Join Date
    Sep 13 2010
    Location
    Gods Own (NZ)
    Posts
    1,302
    What is this supposed to do?

    Code:
    missionnamespace [_trgname,createTrigger ["emptyDetector",getpos _x]];

    "Learn by doing!" - Quoted from a post by Imutep

    OUTERRA - OUTERRA - OUTERRA - OUTERRA - BLOWMIND!

  6. #6
    Quote Originally Posted by twirly View Post
    What is this supposed to do?

    Code:
    missionnamespace [_trgname,createTrigger ["emptyDetector",getpos _x]];
    sorry typo
    fixed now

    ---------- Post added at 13:30 ---------- Previous post was at 13:10 ----------

    best i can come up with is to use

    Code:
    (call compile _trgname) settriggerstatements ["this","hint 'trigger is on'","hint 'trigger is off'"];
    is there a better way to do it?

  7. #7
    Quote Originally Posted by zorilya View Post
    is there a better way to do it?
    PHP Code:
    _trigger missionNamespace getVariable _trgname;
    _trigger setTriggerStatements ["this","hint 'trigger is on'","hint 'trigger is off'"]; 

Similar Threads

  1. Position variables and how to make them from separate variables?
    By Tankbuster in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 5
    Last Post: Feb 21 2012, 23:23
  2. Dynamically spawned mission - how to check for local variables
    By Igneous01 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 3
    Last Post: Apr 5 2011, 05:03
  3. Making dynamically the name of variables?
    By blackgrain in forum ARMA - MISSION EDITING & SCRIPTING
    Replies: 4
    Last Post: Jul 2 2007, 09:46
  4. Dynamically getting town names?
    By Taurus in forum ARMA - MISSION EDITING & SCRIPTING
    Replies: 9
    Last Post: Jun 30 2007, 12:03
  5. Dynamically improving skills
    By Shadow in forum ARMA 2 & OA - SUGGESTIONS
    Replies: 21
    Last Post: Apr 20 2004, 16:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •