Home   Help Search Login Register  

Author Topic: Using AND and OR together in a conditional  (Read 1336 times)

0 Members and 1 Guest are viewing this topic.

Offline tcp

  • Members
  • *
    • Violator Gaming
Using AND and OR together in a conditional
« on: 25 Aug 2009, 18:34:01 »
I created a trigger with ((getpos (thislist select 0)) select 2 > 1) && (("Plane" countType thislist  > 0) || ("Helicopter" countType thislist  > 0)) as the condition. It works with just the OR statement but not with the AND statement added.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Using AND and OR together in a conditional
« Reply #1 on: 25 Aug 2009, 18:45:51 »
Try changing:
Code: [Select]
((getpos (thislist select 0)) select 2 > 1)--->
(((getpos (thislist select 0)) select 2) > 1)

Anyway, this might generate errors as if the trigger area is empty, then thisList is empty and then (thislist select 0) is not possible.

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Using AND and OR together in a conditional
« Reply #2 on: 25 Aug 2009, 20:39:44 »
Thanks for the reply, I found out that I just had a wrong name for something in the trigger. So both the original and the correction work.

BTW, I now have a cool trigger to have a light next to a service point turn off when planes or helicopters come close, turn it on during the repair, and back off again when they start to leave. Had to use isEngineOn instead of the getpos height. It looks like this:

Condition:
((("Plane" countType thislist  > 0) || ("Helicopter" countType thislist  > 0))) && (isEngineOn (thislist select 0))
On Act:
tlight1 action ["lightOff", tug1];
On Dea:
tlight1 action ["lightOn", tug1];

tlight1 is the game logic orginally used to turn the lights on in the empty tug.
tug1 is the tug.
« Last Edit: 25 Aug 2009, 20:49:10 by tcp »