Jump to content
thy_

How to storage trigger's var names in array, and then call them through forEach loop? [SOLVED]

Recommended Posts

Pretty sure I'm stepping through a basic question but, really, I've TRIED hard all this afternoon to find out on my own how to make the forEach understand the array content are trigger variable names already dropped in place via Eden Editor.

 

myTriggersVarNames =
[
    "myTrg1",
    "myTrg2",
    "myTrg3"
];

while {true} do {

    // Doesn't work:
    { 
        if (player inArea _x) then {
            systemChat "Player inside the trigger";
        };
	
    } forEach myTriggersVarNames;

    // Working fine:
    /* 
    if (player inArea myTrg1) then {
        systemChat "Player inside the trigger"
    };
    */

	sleep 3;

}

 

Share this post


Link to post
Share on other sites
myTriggersVarNames =
[
    "myTrg1",
    "myTrg2",
    "myTrg3"
];

This is an array of strings.

 

myTriggersVarNames =
[
    myTrg1,
    myTrg2,
    myTrg3
];

This is an array of variable names.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

You right, @Harzach. I didn't notice, even though with the error below, that forEach works in my tries with no quotes. 

 

Some advice to avoid this error? It says the trigger var names are not defined. How can I define them since they're just triggers?

 

image.png

 

 

 

 

Share this post


Link to post
Share on other sites

Forget. 🤣 If the Trigger's array got one or more vanames and those triggers don't exist on Eden Editor, the "Error Undefined Variable" is shown up.

Thanks.

  • Like 1

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

×