EDIT: Nevermind I realize the if statement occurs before and after the index is added to therefore making it possible to trigger the if statement even when it is 0 and since the index only goes up to the amount of nextStates there are then nothing will happen if the wrong key is pressed. And since it loops through each iteration per frame then resets, that means we can press any key and will be valid for each of those iterations. Correct?
I’ve seen some posts here but I still do not understand. When the for statement is active it creates an integer called ‘index’ and if it is lesser than the amount of nexStates available then it will add 1 to the for statement until it is null? If so then when exactly does the ‘if’ statement occur? when the loop is null or when it is looping before it becomes null? And when it does trigger then the if statement checks if I am pressing the corresponding key number plus the index (Like 1+2 is 3 so it only checks for 3?)
or does it check for the key number and the index number?
And even if the ‘if’ statement is true does it change the current amount of available states to choose from to the amount of the index? if so is it the current index amount from the for loop or the current index amount from the ‘if’ statement?
And wouldn’t make it so it will eventually stop at the maximum amount of nextStates available therefore making the very last option the only one that can be selected??