if statements not returning as expected, anybody know why?

read bold only for shorter description

Im programming an inventory, ive set it(i think) to work by pressing arrow keys. Pressing Up Arrow or Down Arrow navigate between arrays. “skillbag”, “magicbag”, and “itembag”, but for some reason excluding the itembag. It never “selects” itembag as the var activeCursor(thats what i use as my variable that is the selected array). Im assuming my If statements under the comment “SET THE ACTIVE CURSOR” are correct… but they arent returning as i thought they would, any idea why?

var itembagCursor : int = 0;
var itembagCursorMax : int = 0;
var skillbagCursor : int = 0;
var skillbagCursorMax : int = 0;
var magicbagCursor : int = 0;
var magicbagCursorMax : int = 0;
var selectedSkill : String;
var selectedMagic : String;
var selectedItem : String;
private var activeCursor : String = "skillbag";

function Start(){

    Master.itembag.AddRange(Array("Potion","Ether","Antidote")); //add item to inventory
	itembagCursorMax = itembagCursorMax + 2;
    Master.skillbag.AddRange(Array("Cross Cut","Dolphin Kick","X-Cut","Slam")); //add multiple items
    skillbagCursorMax = skillbagCursorMax + 3;
    Master.magicbag.AddRange(Array("Fire","Blizzard","Thunder","Aero"));
    magicbagCursorMax = magicbagCursorMax + 3;
    //Master.inventory.Sort(); //sort inventory
    //Master.skillbag.Remove("slam"); //remove first instance of item

}

function Update(){
selectedItem = Master.itembag[itembagCursor];
selectedMagic = Master.magicbag[magicbagCursor];
selectedSkill = Master.skillbag[skillbagCursor];

/* SET THE ACTIVE CURSOR */

	if(activeCursor == "skillbag" && Input.GetKeyDown(KeyCode.UpArrow)){
		activeCursor = "itembag";
	}
	
	if(activeCursor == "skillbag" && Input.GetKeyDown(KeyCode.DownArrow)){
		activeCursor = "magicbag";
	}
	
	if(activeCursor == "magicbag" && Input.GetKeyDown(KeyCode.UpArrow)){
		activeCursor = "skillbag";
	}
	
	if(activeCursor == "magicbag" && Input.GetKeyDown(KeyCode.DownArrow)){
		activeCursor = "itembag";
	}
	
	if(activeCursor == "itembag" && Input.GetKeyDown(KeyCode.UpArrow)){
		activeCursor = "magicbag";
	}
	
	if(activeCursor == "itembag" && Input.GetKeyDown(KeyCode.DownArrow)){
		activeCursor = "skillbag";
	}
	
/* ENABLE ACTIVE CURSOR TO NAVIGATE ITEMS <- & -> */

	if(Input.GetKeyDown(KeyCode.LeftArrow) && activeCursor == "itembag"){
		itembagCursor = itembagCursor - 1;
	}
	if(Input.GetKeyDown(KeyCode.RightArrow) && activeCursor == "itembag"){
		itembagCursor = itembagCursor + 1;
	}
	if(Input.GetKeyDown(KeyCode.LeftArrow) && activeCursor == "magicbag"){
		magicbagCursor = magicbagCursor - 1;
	}
	if(Input.GetKeyDown(KeyCode.RightArrow) && activeCursor == "magicbag"){
		magicbagCursor = magicbagCursor + 1;
	}
	if(Input.GetKeyDown(KeyCode.LeftArrow) && activeCursor == "skillbag"){
		skillbagCursor = skillbagCursor - 1;
	}
	if(Input.GetKeyDown(KeyCode.RightArrow) && activeCursor == "skillbag"){
		skillbagCursor = skillbagCursor + 1;
	}
	
/* DONT ALLOW THE CURSOR TO NOT BE ON AN ITEM IN THE ARRAY AKA BLANK(NULL) */

	if(itembagCursor > itembagCursorMax){
		itembagCursor = 0;
	}
	if(itembagCursor < 0){
		itembagCursor = itembagCursorMax;
	}
	if(skillbagCursor > skillbagCursorMax){
		skillbagCursor = 0;
	}
	if(skillbagCursor < 0){
		skillbagCursor = skillbagCursorMax;
	}
	if(magicbagCursor > magicbagCursorMax){
		magicbagCursor = 0;
	}
	if(magicbagCursor < 0){
		magicbagCursor = magicbagCursorMax;
	}
}

function OnGUI(){
	GUI.Label(Rect(0,Screen.height - 60,30,20), selectedSkill);
	GUI.Label(Rect(0,Screen.height - 40,30,20), selectedMagic);
	GUI.Label(Rect(0,Screen.height - 20,30,20), selectedItem);
}

The reason that you never get the itembag cursor is because its get changed back to a magicbag or a skillbag by the design of your code.

If we look at this part of your code ( I cut out some of it to make it smaller and easier to see):

    if(activeCursor == "skillbag" && Input.GetKeyDown(KeyCode.UpArrow)){
       activeCursor = "itembag";
    }

    if(activeCursor == "itembag" && Input.GetKeyDown(KeyCode.UpArrow)){
       activeCursor = "magicbag";
    }

First you set the activeCursor to be a itembag. BUT since the activeCursor now is a itembag, then the next if-statement will change it to a magicbag, because since it has changed to a itembag the next if-statement is also true.

So, you need to redesign your code a little. The easiest way would be to use else if-statements for the underlying if-statements:

    if(activeCursor == "skillbag" && Input.GetKeyDown(KeyCode.UpArrow)){
       activeCursor = "itembag";
    }
    else if(activeCursor == "itembag" && Input.GetKeyDown(KeyCode.UpArrow)){
       activeCursor = "magicbag";
    }

In this case, if the first if-statement is true, then the activeCursor will be a itembag. And it will ignore the next else if-statement. If the first if-statement is false, then it will check the next else if-statement. So use if for the first if-statement, and else if-statements for the rest of them.

But as you might want to add new things to your game, your if- and else if-statements would increase and make everything much harder for you to write and handle. So I think it would be best if you redesigned this part of the code to be more dynamic.

A example is to use a switch-statement to help you make it easier:

if(Input.GetKeyDown(KeyCode.UpArrow) == true)
{
    switch(activeCursor) 
    {
        case "skillbag":
            activeCursor = "itembag";
            break;
        case "magicbag":
             activeCursor = "skillbag";
             break;
        case "itembag":
            activeCursor = "magicbag";
            break;
    } 
} 
// We dont want the user to press up and down at the same time.
else if(Input.GetKeyDown(KeyCode.DownArrow) == true)
{
    switch(activeCursor) 
    {
        case "skillbag":
            activeCursor = "magicbag";
            break;
        case "magicbag":
             activeCursor = "itembag";
             break;
        case "itembag":
            activeCursor = "skillbag";
            break;
    } 
} 

Good luck!