Comrades in Arms Discussion Board

Full Version: OR operator not working?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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
(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.
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
(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.
did you try a = true
(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.
(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.