[Solved] Recalling an int, gives an "empty" spot.

Hello all,
It’s me again and I got a small question: Does anyone know the best way to recalling an int that was made with a “for” line? I’m currently using a code where I am doing this:

Screen.room.block[blockY][blockX] = Screen.room.block[y][x];

The only problem is, the previous blockY and blockX are “empty” when you press your LMB. the airID and the groundID are 0 when I press my LMB. I need to “recall” the ints for another script, because when I upgrade a tower it needs to know where to upgrade. My code can be a little bit odd. I’m fairly new to programming.
my whole code:

		if(mouseButton == 1) { 
			for(int y = 0; y<Screen.room.block.length;y++) {
				for(int x = 0; x<Screen.room.block[0].length;x++) {
					if(Screen.room.block[y][x].contains(Screen.mse)){
						Screen.room.block[y][x].rangeVisible = true;
						Screen.room.block[blockY][blockX] = Screen.room.block[y][x];
                      	if(Screen.room.block[y][x].airID >= 2 && Screen.room.block[y][x].airID <= 7){upgradeScreen = Screen.room.block[y][x].airID -1; upgradeStore = true;}else{upgradeStore = false; upgradeScreen =0;}
					} else {
						Screen.room.block[y][x].rangeVisible = false;
					}
				}
			}
			if(upgradeStore == true){
				for(int i=0;i<upgradeButton.length;i++) {
					if(upgradeButton[i].contains(Screen.mse)) {
						if(upgradeButtonID[i] != Value.airAir) {
							if(upgradeButtonID[i] == Value.airUpgrade) { 
								if(Screen.money >= upgradePrice){
									if(Screen.room.block[blockY][blockX].airID != 4 ){
										Screen.room.block[blockY][blockX].airID += 1;
										Screen.money -= upgradePrice;
										upgradeScreen += 1;
									}
								}
							}
							if(upgradeButtonID[i] == Value.airSell){
							    Screen.room.block[blockY][blockX].sell();
								Screen.money += sellPrice;
							}
						}
					} 
				}
			}

Screen before pressing LMB

http://imageshack.us/a/img21/8179/storeoff.th.jpg

Screen after pressing LMB

http://imageshack.us/a/img834/4981/problemai.th.jpg

-Roseslayer
Already thanks!

I’m not sure I entirely understand your question, but can’t you just make a variable that stores it?

for example StoredX and StoredY? and then use those?

I thought to do that the same, so i made blockX and blockY as store places. only when the store gets his first x and y, the blockX and blockY (that are 0 at start) are changing to x and Y (2 and 3 as example so blockX = 2 and blockY =3, but the other values 0,0 are gone and so are the groundID and the airID of that block.
if i change the blockY on start to 3 and blockX to 3 then at (2,2) there’s an “empty” spot, do you understand this better? cause I don’t know how I can explain it good.

-Roseslayer
thanks already!

There is a few solutions you can do.

  1. You can store an array of ints if you need the previous values for multiple entries.

  2. I think an easier solution might be to have a boolean within the Screen.class like [icode] boolean upgrade [/icode]. You can iterate through the loop and whatever [icode] Screen [/icode] needs the upgrade will be automatically updated, then set that variable to false afterward.

  3. If it needs to be updated to a certain point. You can store [icode] int upgrade [/icode] in the Screen.class instead. This way you’ll be able to tell a tower exactly how far you want it to upgrade. If the tower isn’t at the number upgrade in the Screen.class, then it is time to upgrade it.

[EDIT]
Solved it,

Screen.room.block[blockY][blockX] = Screen.room.block[y][x];
that needs to be
{blockY=y; blockX=x;}