Game save

Explanation
Many games offer the player the possibility of saving the game and loading a saved game. In Game Maker this happens automatically when the player press  for saving and  for loading. You can also save and load games from within a piece of code (note that loading only takes place at the end of the current step).

What things are saved?
Please realize that only the basic game data is being saved. That data are:
 * All global variables
 * All current room settings.
 * All instances of current room with their local variables.
 * All settings of all persistent rooms.
 * All instances of all persistent rooms.

The settings of room include size, caption, tiles, background and views settings, but exclude the room's name (because it is just a GML constant, not a string).

What things are not saved?

 * The sounds and background music currently played.
 * Changed resources.
 * Contents of data structures.
 * Particle systems and Particles.
 * Multiplayer settings.
 * Surfaces.
 * 3D Models and Settings.

How to save unsaveable things?
Some things still can be saved, while it is not easy mechanics. To achive this, you must:
 * 1) Define special object that in his Step event, perform necessary tasks and they destroys self.
 * 2) When you need to save game, create this object before saving game and then destroy it just after game is saved.

However, not all thing can be saved such way, because some of these things cannot be achieved with GML functions.

Sound and background music
You can save sounds and music currently played, testing all resources with sound_isplaying. However, you cannot save sound/music playing position.

Also you can create specific objects that being loaded just start playing specific background music or sounds.

Changed resources
You cannot save modified resources that way, but you can create 'Resource modifier' object, that explicitly loads necessary resources according to internal list (of course, this list must be an array).

Contents of data structures
Easy scan all necessary structures and store them in variables of special object. Then after loading recreate structures and put data back. Game Maker 8 has special set of functions to save contents of data structures into string variables and to restore them back.
 * Stacks: ds_stack_write(id) and ds_stack_read(id,str).
 * Queues: ds_queue_write(id) and ds_queue_read(id,str).
 * Lists: ds_list_write(id) and ds_list_read(id,str).
 * Maps: ds_map_write(id) and ds_map_read(id,str).
 * Priority queues: ds_priority_write(id) and ds_priority_read(id,str).
 * Grids: ds_grid_write(id) and ds_grid_read(id,str).

Particle systems and Particles
Create particle systems, particle types and so on with special objects. Don't forget to put references to them into some object you don't destroy or into global variables. Note that exact particles positions, speed and lifetime cannot be saved cause cannot be obtained. However, you can save number of particle system steps and replay them, or just do some hidden particle steps.

Multiplayer settings
Note that multiplayer settings can be saved such way but it is rather wrong. Multiplayer games themselves often cannot be saved or can be saved by server side only. Also there is not very useful to save multiplayer settings.

Surfaces
Surfaces cannot be saved.

3D Graphics
3D Graphics setting can be saved, but you probably won't make the game that can be saved both in 2D and in 3D mode. Also, you could not save current transformation or 3D models. However, you can just save 3D models as files and then load them when necessary.

Alternate saving
The more complicated mechanism of saving game may be achieved with file handling routines but this goes beyond the scope of this topic.