Switch/case range syntax question

Posted:
Fri Mar 11, 2011 3:28 am
by yttermayn
If I have a range of values I want to trigger a certain case using the switch statement, what is the syntax for that in game editor?
Like if I want the numbers 1 through 3 to be included in the first case, 4 through 20 in the second case, etc.
Re: Switch/case range syntax question

Posted:
Fri Mar 11, 2011 4:12 am
by rykein
you cant. if you are dealing with ranges you should probably use if. for your example though you might do this.
- Code: Select all
switch(variable)
{
case 1:
case 2:
case 3:
break;
default:
if(variable>=4 && variable<=20)
{
//
}
break;
}
though at that point you might as well use ifs.
Re: Switch/case range syntax question

Posted:
Fri Mar 11, 2011 5:27 am
by yttermayn
That's what I was afraid of. Thanks!