First time user of GMS 2 (started yesterday). I have no clue how instances and their functions work so I would not be surprised to use the wrong functions or even to use the right function in a wrong way.
I'm trying to have an instance check if all the instances in the room (including itself) have an "ini" score lower than the current "global.turn". If there is, then the "global.turn" should become the highest "ini" lower than the "global.turn". If there is no "ini" lower than the "global.turn" then it becomes the highest "ini" in the room.
The code I tried.
Edit: Found the problem, "turn" doesn't exist, it was supposed to be "global.turn".
I'm trying to have an instance check if all the instances in the room (including itself) have an "ini" score lower than the current "global.turn". If there is, then the "global.turn" should become the highest "ini" lower than the "global.turn". If there is no "ini" lower than the "global.turn" then it becomes the highest "ini" in the room.
The code I tried.
Code:
nextTurn=-1000;
maxTurn=0;
for(var i =0; i< instance_count;i++){
if(instance_find(all,i).ini < global.turn){
nextTurn=max(nextTurn,instance_find(all,i).ini);
}else{
maxTurn=max(maxTurn,instance_find(all,i).ini);
}
}
if(nextTurn = -1000){
turn=maxTurn;
}else{
turn=nextTurn;
}
Last edited: