Jump to content
Sign in to follow this  
TemichSablin

waitUntil + or

Recommended Posts

So basically i need to make a script that releases once any of the three conditions is met. The code below doesn't work and produces no errors, just like the biki says.

Something like

waitUntil {(mtask1override) or (!(alive pmcsuv)) or (timerdone)};

if the override is on, or the pmcsuv is destroyed, or the time runs out, the waitUntil releases.

Share this post


Link to post
Share on other sites
So basically i need to make a script that releases once any of the three conditions is met. The code below doesn't work and produces no errors, just like the biki says.

Something like

waitUntil {(mtask1override) or (!(alive pmcsuv)) or (timerdone)};

if the override is on, or the pmcsuv is destroyed, or the time runs out, the waitUntil releases.

Try this:

waitUntil {((mtask1override) or (!(alive pmcsuv)) or (timerdone))};

Share this post


Link to post
Share on other sites

try:

waitUntil {(mtask1override or !alive pmcsuv or timerdone)};

else just do a while loop

while {true} do {
  if (mtask1override) then {false};
  if (!alive pmcsuv) then {false};
  if (timerdone) then {false};
  sleep 1;  // checks all conditions every second, adjust downwards to fex 0.1 for faster response
};

  • Like 1

Share this post


Link to post
Share on other sites

You have to define the variables first, otherwise waitUntil acts up if it has multiple conditions.

The parentheses in waitUntil are all unnecessary unless you want to bundle certain conditions in the same parentheses. They're required only when the normal sequence would mess with what you want the commands to take into account. and and or always cut the sequence.

For example:

The value of _this select 1 is 1.

100+_this select 1 returns 101.

_this select 1+100 gives an error because the select command waits until 1+100 is calculated and supposedly the _this array doesn't have 102 elements.

(_this select 1)+100 returns 101 again.

Edited by Celery

Share this post


Link to post
Share on other sites

while {mt1st} do {
  if (mtask1override) then {mt1st = false};
  if (!alive pmcsuv) then {mt1st = false};
  hint "mission1";
  if (timerdone) then {mt1st = false};
  sleep 1;  // checks all conditions every second, adjust downwards to fex 0.1 for faster response
};

this worked with mt1st being defined before. thanks to everyone

Edited by TemichSablin

Share this post


Link to post
Share on other sites
while {mt1st} do {
  if (mtask1override) then {mt1st = false};
  if (!alive pmcsuv) then {mt1st = false};
  hint "mission1";
  if (timerdone) then {mt1st = false};
  sleep 1;  // checks all conditions every second, adjust downwards to fex 0.1 for faster response
};

this worked with mt1st being defined before. thanks to everyone

Hi,

Well, that is far from a good solution.

That could be easily converted to:

waitUntil { sleep 1; (mtask1override || (!alive _pmcsuv) || timerDone) };

_neo_

  • Like 1

Share this post


Link to post
Share on other sites

Or just waitUntil {mtask1override or !alive _pmcsuv or timerDone};

Share this post


Link to post
Share on other sites

This checks every frame - which is most likely not necessary.

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
Sign in to follow this  

×