How can I --NOT-- use if?
Posted: Wed Mar 21, 2012 8:21 pm
What are some of the best ways to "Not" use if statements? For exapmle, the shortest way of creating something like.. well like this, but without the if's
I know there's "Switch" like this:
But is there an easier way?
I was thinking something like:
But then you'd still have to use if statements to change the armor.
- Code: Select all
if(ArmorPiece==1)
{
///
}
if(ArmorPiece==2)
{
///
}
if(ArmorPiece==3)
{
///
}
if(ArmorPiece==4)
{
///
}
if(ArmorPiece==5)
{
///
}
if(ArmorPiece==6)
{
///
}
if(ArmorPiece==7)
{
///
}
if(ArmorPiece==8)
{
///
}
if(ArmorPiece==9)
{
///
}
if(ArmorPiece==10)
{
///
}
I know there's "Switch" like this:
- Code: Select all
switch(ArmorPiece)
{
case 0: break;
case 1: break;
case 2: break;
case 3: break;
case 4: break;
case 5: break;
case 6: break;
case 7: break;
case 8: break;
case 9: break;
case 10: break;
}
But is there an easier way?
I was thinking something like:
- Code: Select all
ArmorPiece = 0 + var;
But then you'd still have to use if statements to change the armor.