How to see if 1 out of 3 bools is true...and then 2 out of 3

Started by Joseph, Mon 16/08/2010 20:12:33

Previous topic - Next topic

Joseph

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".

??? ???
Spread the love...One.Turtle.At.A.Time.
http://www.youtube.com/watch?v=y0A77rohcyg

GarageGothic

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:

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


Etc.

Joseph

Spread the love...One.Turtle.At.A.Time.
http://www.youtube.com/watch?v=y0A77rohcyg

SMF spam blocked by CleanTalk