Savefile structure - coldrockgames/gml-raptor GitHub Wiki
NOTE: The Savegame system can always only iterate over the current room and persistent objects!
If you want to save some data from the main menu before the game starts, you should save the main menu
state in a savegame file, and during the level, save the level data to another save game file.
Think in room-scope!
By default, all Saveable objects will be part of the savegame file.
Use the declared instance variable add_to_savegame and set it to false if you want to skip specific instances from being saved.
raptor defines these objects as children of Saveable:
LGTextObject-
StatefulObjectRaceObjectRaceTable
RaceController
This information is saved for each object instance in addition to the data variable. You do not need to store position or movement information in data. It's taken directly from the object instance.
seed |
The current seed of the randomizer |
| INSTANCE FIELDS | |
obj |
The object type |
id |
The instance id (as reference for restoring) |
x and y
|
The current position |
direction and speed
|
Movement information |
layer and depth
|
The name of the layer (if available) and depth, where the object exists |
| OBJECT FIELDS | |
visible, persistent, and solid
|
Object flags |
| SPRITE/IMAGE FIELDS | |
sprite_index and image_index
|
Sprite and Frame number |
image_speed |
Sprite animation speed |
image_alpha and image_blend
|
Transparency and color blend |
image_angle, image_xscale and image_yscale
|
Rotation and scaling |
In addition to the list above: All raptor platform objects (like the Race...objects) will automatically save their states and even restore their instance links (like the RaceController variable on a RaceTable object)!
You do not need to save race_table_name and other RACE variables manually.
This is an (almost empty) example file to help visualizing the structure. You can see the root nodes ("instances", "engine", "race_tables", "structs" and "global_data") here. There is only one single instance contained in the savegame, which makes it easy to track the fields of an object, that are saved.
This savegame has been created through the Save Button of the gml-raptor-demo project, where you can enter your name and click Save to demonstrate the Savegame system.
{
"instances" : {
"inst0" : {
"x" : 32,
"solid" : 0,
"image_xscale" : 1,
"image_angle" : 0,
"depth" : 300,
"image_blend" : 16777215,
"layer" : "Instances",
"direction" : 0,
"image_index" : 320,
"obj" : "ProfileData",
"y" : -32,
"visible" : 1,
"image_yscale" : 1,
"persistent" : 0,
"image_alpha" : 1,
"__raptor_savegame_ref_id" : 100041,
"image_speed" : 1,
"speed" : 0,
"sprite_index" : -1,
"data" : {
"player_name" : "Player"
}
}
},
"engine" : {
"seed" : 2616892371
},
"race_tables" : {},
"structs" : {},
"global_data" : {}
} Continue reading in Planning your Savegame.