OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Undeceived on 03 Sep 2008, 01:26:46

Title: How to check if xy = true or xy = false ?
Post by: Undeceived on 03 Sep 2008, 01:26:46
Hi guys.

I found a thread about this issue, but it was not very helpful to me...


I have a chopper patroling around. When the player reaches a certain trigger, a script is launched that checks if xy = true or false. If it's true, the chopper has to fly to position A, if xy = false, it has to fly to position B.

How would this script have to look?

I tried

? xy = true : chopper to A
? xy = false : chopper to B

but obviously I received a error message, this seems not to be the right way to check it.


Would be glad if someone can give me a good code. :)

Thank you very much!!
Title: Re: How to check if xy = true or xy = false ?
Post by: Spooner on 03 Sep 2008, 01:54:21
= is used for assignment, but == tests for equality. Can be confusing at first, since you are used to = being used for equality in mathematics.

Thus, this is what you could have done to get the result you expected.
Code: [Select]
? xy == true : chopper to A
? xy == false : chopper to B

However, since ?: checks for true/false anyway, it is more usual to:
Code: [Select]
? xy : chopper to A
? not xy : chopper to B
Title: Re: How to check if xy = true or xy = false ?
Post by: Undeceived on 03 Sep 2008, 02:15:30
Aah, great!

Thank you, Spooner! It works perfectly! :good: