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!