@Noele: come on guys, it's not a save_game, but load_game,
Read carefully and you will realize he discusses about game load even though the example code uses game_save. And actually, the solution to your problem involves game_save, as discussed later.
He is right about that game_load doesn't immediately take effect. The actual loading takes place at the end of the current step (as mentioned in the manual, right above the description of game_load.) So, what is actually happening is:
- You execute game_load (the actual loading doesn't take place here!)
- You read global variable from the ini file
- After that, Game Maker actually loads the file, resetting all of variables set in the step (2).
Your codes were actually executed, but immediately got overwritten with values in the saved game.
On the other hand, game_save takes place at the right moment it is executed. Here is the trick: you can save something in the file and reset it in the game so that it only takes effect when the game is loaded. For example, you can set an alarm in the saved game.
alarm = 1;
alarm = -1;
The alarm doesn't actually go off in the game, because it is reset to -1 instantly. However, the alarm is saved in the file. When you load the file, the alarm will be turned on when the loading actually takes place
. You can use it to trigger loading the ini file. Now, the loading code becomes a single line:
// Loading the file will set alarm to 1.
And all of the rest will be into the alarm event.
// Alarm 0 event
global.tool = 1;
// and so on
Edited by torigara, 19 June 2012 - 01:04 PM.