Welcome, Guest Monday 21st April 2014, 13:55:43
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: [SOLVED] Boolean Operator ||  (Read 200 times)
0 Members and 1 Guest are viewing this topic.
Carroll
*
Offline Offline


Mission Designer (MP-"well tryin to capiche"


« on: 13 Aug 2009, 04: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, 06:34:15 by Carroll » Logged
jones
*
Offline Offline


« Reply #1 on: 13 Aug 2009, 04:55:02 »

Code:
if ((trig1) || (trig2)) then {
       code......
};

I tested all truths wit that statement and it worked fine.
Logged
Carroll
*
Offline Offline


Mission Designer (MP-"well tryin to capiche"


« Reply #2 on: 13 Aug 2009, 05:23:51 »

Code:
if ((trig1) OR (trig2)) then {trigTest=true};
with this in condition line of one trigger

Code:
trigTest
& this in the last

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

anyway thanks for help
Logged
Worldeater
Editors Depot
Administrator
*****
Offline Offline


Suum cuique


« Reply #3 on: 13 Aug 2009, 05: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:
nil OR true

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


Here's another example of this "phenomenon":

Code:
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, 05:44:20 by Worldeater » Logged

try { return true; } finally { return false; }
Carroll
*
Offline Offline


Mission Designer (MP-"well tryin to capiche"


« Reply #4 on: 13 Aug 2009, 06: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!
Logged
Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: