For the save/load scripts, just save global.clear (no array) - you just want to put that one value in the file.
For the world create event, use global.menuClear[] instead of global.clear - the game is crashing because you were defining it as an array in the world create, but using it as a single variable in the save/load files. Using a different name here will fix that. The menu values are for display only, they're not used beyond the main menu.
As for why it's getting the room number - this is because of the order you're loading it in. in the world create, it opens the save file, then does this:
global.menuDeath[i] = first value in file
global.menuTime[i] = second value in file
global.menuDiff[i] = third value in file
global.menuClear[i] = fourth value in file
And if you look in the save/load scripts, you'll see that it saves the room value fourth, so when you read it in the menu, it's getting that room value. Again, using a menuClear array in the world create will solve this.
Now, to make sure that the menu can read it, you should move the clear value save/load to the fourth position in the file:
//...snip...
FS_file_bin_write_dword(f,global.death);
FS_file_bin_write_dword(f,global.time);
if (!dyingSave) { //only save death,time for dying save
FS_file_bin_write_byte(f,global.difficulty);
FS_file_bin_write_byte(f,global.clear); //////put clear here so it's the fourth value in the file
FS_file_bin_write_dword(f,room);
FS_file_bin_write_dword(f,round(x));
FS_file_bin_write_dword(f,round(y));
FS_file_bin_write_byte(f,player.image_xscale+1); //+1 so -1=0, 1=2; bytes have no sign
//new values go under here
FS_file_bin_write_byte(f,global.hasPartner); //just a thing for the game I'm making
}
FS_file_bin_close(f);
Do the same for the load script, and do the same for anything you want to appear in the menu screen.
So, here's the todo list:
- For the world create event, use global.menuClear[] instead of global.clear
- Use global.clear (not array) in save/load scripts
- Move global.clear to fourth position in save/load scripts
Try that out and let me know if it solves your issue!