A switch-statement is like an array of if-statements. They're not very complicated when you know them.
Here's a short example:
int var = 1;
switch(var) {
case 0: {
//Run script for case 0.
break;
}
case 1: {
//Run script for case 1. This one will run because var == 1.
break;
}
case default: {
//Run script if no matching case is found.
break;
}
}
What happens here is that the switch will use the
var variable as its testing value. Depending on the value of
var, different cases will run.
The break; keyword is required so that you don't run more than one case. If you do not have break, it will run case 1 and case
default after case 0 if 0 was accepted. If 0 was denied, but 1 was accepted (which is the case here), then it will run case 1 and case default (I believe).
If you're more familiar with if-statements, here's an example that does the exact same.
int var = 1;
if(var == 0) {
//Run script for case 0.
}
else if(var == 1) {
//Run script for case 1. This one will run because var == 1.
}
else if(var < 0 || var > 1) {
//Run script if var does not match above. This one runs if var is less than 0 or more than 1, EG anything but the above if-statements.
}