Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Baconator

waitUntil exits at first true boolean value or executes until the end of code block?

Recommended Posts

i couldnt find it in/understand the waitUntil wiki, so i thought i would ask.

Does waitUntil exit after the first true boolean it sees or does it keep executing the code block?

example:

_var = 1;
waitUntil {
   if (_var == 0) exitWith {true;};
   if (_var == 1) exitWith {true;};
   if (_var == 2) exitWith {true;};
   false;
};

so the code block in the waitUntil would look like this after evaluating the conditional statements:

waitUntil {
   false;
   true;
   false;
   false;
};

would the waitUntil end at the first true or does the last value need to be true? :confused:

Share this post


Link to post
Share on other sites

It'd exit the current scope (waitUntil?). I'd suggest lazy evaluation instead of the 'ifs' / exitWith.

waitUntil {_var == 0 || {_var == 1 || {_var == 2}}}; //Will stop evaluating and go on with the script as soon as any one of the conditions returns true. 
//other stuff

Edited by Iceman77

Share this post


Link to post
Share on other sites

ok thats what i thought, but i just wanted to make sure. Thank you.

As for the lazy evaluation, I'm gonna wait to optimize until i get the mission actually working first lol might save myself a few grey hairs.

Share this post


Link to post
Share on other sites

The last value of waitUntil scope has to return true. Using exitWith {true} essentially does that too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×