Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Joseph on Mon 16/08/2010 20:12:33

Title: How to see if 1 out of 3 bools is true...and then 2 out of 3
Post by: Joseph on Mon 16/08/2010 20:12:33
Hi friends, its me, Joseph!

HOW do i do this--->

3 boolean vars: a,b,c

I waNT TO chek if 1 of the variables is true, and then if 2 of the three is true...

How can I write that so its not too long of a line? Like i want to pass "if one of these three is true, do this" and "else if 2 of the three is true, do that".

??? ???
Title: Re: How to see if 1 out of 3 bools is true...and then 2 out of 3
Post by: GarageGothic on Mon 16/08/2010 20:23:40
If I'm not mistaken, bools are simply ints that are limited to values of either 0 or 1, so you should be able to treat them as numeric values. So to see if one is true:

int total = a+b+c;
if (total == 1) DoSomething();
else if (total == 2) DoSomethingMore();


Etc.
Title: Re: How to see if 1 out of 3 bools is true...and then 2 out of 3
Post by: Joseph on Mon 16/08/2010 20:25:05
wowch thats smart!  :o

i thank you sir