NateAnimates59
Member
Hello community! I have an inquiry regarding how complicated code can get until GameMaker passes on a code the wrong way or fails completely. I have a long sample of code (abridged herein for surveying purposes) that has multiple if and multiple switch statements in an array in which every one of them is inside the brackets ( { } ) of another. The array has up to 4- or 5-ish layers of this in a few of the objects' events.
Now, the issue is that even though I have a case clearly defined and clearly broken with the "break;" commands on the right places before the appropriate brackets, one case seems to override the other. Where the code comments describe the Placeholder and Grammar Modes, it should label 1 as the Placeholder case for the Questions Mode and 2 for Grammar. Can anybody help me out with this or with finding a better way of writing code at all?
Code samples:
Objt_Choice A \ Create Event \
vSelected = 0; TouchingGamePad = 0;
Obj_Choice A \ Left-Pressed Event \
//It becomes selected in pontentiality.
vSelected = 1;
*This event especially has an abridged version herein of the longer set of similarly structured sections of code by category, by level/question, and by the Questions Mode. It almost repeats the exact format of code sequences with exceptions of nitty-gritty things like the values.*
Objt_Choice A \ Step Event \
if(vSelected==1){
switch(global.QuestionsMode){
//Case 1 is the Placeholder Case.
case 1:
//The beginning of checking for the CategoryA room.
if(room==rm_CategoryA){
//This condition below regards the question from category A, 100 points.
if(global.jquestion=="Answer A0"){
//Answer A0 is right.
//Level 100A would stop existing if the player got it right.
global.lOneA_exist=0;
//100 points times the level number without the two zeros attached adds to the respective team's score.
//But first, it has to check the current team having made the choice.
switch(global.CurrentTeam){
case 1:
global.TeamAScore+=(100*global.vLevelSelect);
//Finally, it goes to the room for being correct.
room_goto(rm_CorrectAns); break;
case 2:
global.TeamBScore+=(100*global.vLevelSelect);
//Finally, it goes to the room for being correct.
room_goto(rm_CorrectAns); break;
}
}
}
}
}
Now, the issue is that even though I have a case clearly defined and clearly broken with the "break;" commands on the right places before the appropriate brackets, one case seems to override the other. Where the code comments describe the Placeholder and Grammar Modes, it should label 1 as the Placeholder case for the Questions Mode and 2 for Grammar. Can anybody help me out with this or with finding a better way of writing code at all?
Code samples:
Objt_Choice A \ Create Event \
vSelected = 0; TouchingGamePad = 0;
Obj_Choice A \ Left-Pressed Event \
//It becomes selected in pontentiality.
vSelected = 1;
*This event especially has an abridged version herein of the longer set of similarly structured sections of code by category, by level/question, and by the Questions Mode. It almost repeats the exact format of code sequences with exceptions of nitty-gritty things like the values.*
Objt_Choice A \ Step Event \
if(vSelected==1){
switch(global.QuestionsMode){
//Case 1 is the Placeholder Case.
case 1:
//The beginning of checking for the CategoryA room.
if(room==rm_CategoryA){
//This condition below regards the question from category A, 100 points.
if(global.jquestion=="Answer A0"){
//Answer A0 is right.
//Level 100A would stop existing if the player got it right.
global.lOneA_exist=0;
//100 points times the level number without the two zeros attached adds to the respective team's score.
//But first, it has to check the current team having made the choice.
switch(global.CurrentTeam){
case 1:
global.TeamAScore+=(100*global.vLevelSelect);
//Finally, it goes to the room for being correct.
room_goto(rm_CorrectAns); break;
case 2:
global.TeamBScore+=(100*global.vLevelSelect);
//Finally, it goes to the room for being correct.
room_goto(rm_CorrectAns); break;
}
}
}
}
}