Comrades in Arms Discussion Board
OR operator not working? - Printable Version

+- Comrades in Arms Discussion Board (http://forum.ciahome.net)
+-- Forum: Comrades in Arms Life (http://forum.ciahome.net/forumdisplay.php?fid=3)
+--- Forum: Mission Making (http://forum.ciahome.net/forumdisplay.php?fid=8)
+--- Thread: OR operator not working? (/showthread.php?tid=2918)



OR operator not working? - Fuiba - 03-01-2015

Hi guys. As you well know I've had problems with the mission ending triggers before. I've been banging my head against the wall for a couple of hours because my mission doesn't end.

So I decided to try if there was some bug about. Tried this with no mods just to make sure:

-Fresh map in the editor, VR map.
-Place one player unit.
-Place the first trigger, activated by Radio Alpha. On activation: a = 1; player sidechat "A triggered";
-Place the second trigger, activated by Radio Bravo. On activation: b = 1; player sidechat "B triggered";
-Place the third trigger, condition: a == 1 OR b == 1;
-On activation on the third trigger: player sidechat "A OR B triggered";

Now the third trigger fires ONLY when the first AND the second trigger have fired. Is this some Arma flavor on common logic or am I missing something?


Re: OR operator not working? - Outlawz7 - 03-01-2015

It's because a and b aren't defined before you define them by Alpha/Bravo trigger. I had the same result as you until I added "a = 0; b = 0" in my unit's init line to define a and b.


AFAIK ArmA3 cracked down on undefined variables  Wink ;D


Re: OR operator not working? - Fuiba - 03-01-2015

(03-01-2015, 07:07 PM)Outlawz7 link Wrote: It's because a and b aren't defined before you define them by Alpha/Bravo trigger. I had the same result as you until I added "a = 0; b = 0" in my unit's init line to define a and b.

AFAIK ArmA3 cracked down on undefined variables  Wink ;D

FFS I'm dumb Big Grin Thanks!

Edit: no, I take that back! I'm not that dumb. Arma shouldn't even care about the right side of the expression as long as a == 1 holds true.


Re: OR operator not working? - Outlawz7 - 03-01-2015

But the right side of the OR isn't true or false, it's undefined.


Quote:a: Boolean - Test condition or variable that returns Boolean.


b: Boolean - Test condition or variable that returns Boolean.


https://community.bistudio.com/wiki/or


Re: OR operator not working? - Fuiba - 03-01-2015

(03-01-2015, 07:26 PM)Outlawz7 link Wrote: But the right side of the OR isn't true or false, it's undefined.

https://community.bistudio.com/wiki/or

Oh, right. I guess I automatically assumed that it used lazy evaluation. I don't think I've never used a programming/scripting language that works like this.


Re: OR operator not working? - Watchmen - 03-01-2015

did you try a = true


Re: OR operator not working? - Outlawz7 - 03-01-2015

(03-01-2015, 07:44 PM)Fuiba link Wrote: Oh, right. I guess I automatically assumed that it used lazy evaluation.


It does, read the linked BIKI. It's just my guess than it wants both sides of OR to be either true or false, not something else.


Re: OR operator not working? - Fuiba - 03-01-2015

(03-01-2015, 07:56 PM)Outlawz7 link Wrote: It does, read the linked BIKI. It's just my guess than it wants both sides of OR to be either true or false, not something else.

Yeah, I did, thanks Smile The BIKI has the syntax for lazy evaluation, too.