OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Carroll on 13 Aug 2009, 05:35:35

Title: [SOLVED] Boolean Operator ||
Post by: Carroll on 13 Aug 2009, 05:35:35
Hi Ofpec, not sure if this is a bug or not but i can't seem to get the bolean operator || to work, i've tried, OR as well but it's not working for me like it did in ArmA 1.

in two separate triggers i have
Act: trig1=true;
Act: trig2=true;

in trigger 3 i have
Condition: trig1 OR trig2

from what testing has proved to me || is working exactly the same as &&
can someone verify this as i'm thinking i'm going mad  :blink:
Title: Re: Bolean Operator ||
Post by: jones on 13 Aug 2009, 05:55:02
Code: [Select]
if ((trig1) || (trig2)) then {
       code......
};

I tested all truths wit that statement and it worked fine.
Title: Re: Bolean Operator ||
Post by: Carroll on 13 Aug 2009, 06:23:51
Code: [Select]
if ((trig1) OR (trig2)) then {trigTest=true};with this in condition line of one trigger

Code: [Select]
trigTest& this in the last

still can't get later to activate until both trig1 and trig2 are true in my testing  :dunno:

anyway thanks for help
Title: Re: Bolean Operator ||
Post by: Worldeater on 13 Aug 2009, 06:27:33
Set both variables to false in init.sqf. Otherwise one of them is nil when the check is done. Remember: any expression containing nil is ignored! You probably end up with a check like this:

Code: [Select]
nil OR true

...which is nil and will be ignored (read: trigger won't fire).


Here's another example of this "phenomenon":

Code: [Select]
check = nil;
msg = "Whoa! That's nasty!";
if check then {
  msg = "it's true"
} else {
  msg = "it's false"
};
hint msg; // shows "Whoa! That's nasty!" since the whole if..then..else was ignored!
Title: Re: [SOLVED] Boolean Operator ||
Post by: Carroll on 13 Aug 2009, 07:37:13
Works great now thankyou....i guess this was something i could get away with in the older games (does ring a bell though - maybe i just forgot about it...been a while)

but i know what to do now thanks!