Home   Help Search Login Register  

Author Topic: [SOLVED] Boolean Operator ||  (Read 2270 times)

0 Members and 1 Guest are viewing this topic.

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
[SOLVED] Boolean Operator ||
« 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:
« Last Edit: 13 Aug 2009, 07:34:15 by Carroll »

Offline jones

  • Members
  • *
Re: Bolean Operator ||
« Reply #1 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.

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: Bolean Operator ||
« Reply #2 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

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Bolean Operator ||
« Reply #3 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!
« Last Edit: 13 Aug 2009, 06:44:20 by Worldeater »
try { return true; } finally { return false; }

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: [SOLVED] Boolean Operator ||
« Reply #4 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!