SaveGame¶
9 tools for save game slots: saving, loading, listing and deleting, and serializing actor state.
Back to the index.
delete_save_game¶
Destructive
Delete the save file of a slot with DeleteGameInSlot; the data is gone for good. success is false, with an error, when the engine refuses, usually because the slot does not exist (check with get_save_game_slot_info). Returns slot_name, user_index and message.
| Parameter | Type | Required | Description |
|---|---|---|---|
slot_name |
string | yes | Save slot name to delete |
user_index |
integer | no | Platform user index for the save system; default 0 (the generic desktop save system ignores it) |
Returns: { slot_name: string, user_index: int, success: bool, message: string }
get_save_game_slot_info¶
Read-only
Read the file facts of one save slot without loading or changing it: exists (UGameplayStatics::DoesSaveGameExist) and, for an existing slot, save_path (the generic desktop Saved/SaveGames/<slot>.sav) plus file_size, modified_iso and modified_ticks when that file is on disk. Use it to check one slot before load_game or delete_save_game, or after save_game to confirm the write; to discover slot names use list_save_games; to read the saved object's contents use load_game. A missing slot is a success with exists=false and an error field saying so, and then no save_path, size or time.
| Parameter | Type | Required | Description |
|---|---|---|---|
slot_name |
string | yes | Exact save slot name, e.g. "Slot1", as list_save_games returns it; on desktop it is the file name without .sav. |
user_index |
integer | no | Platform user index, a whole number (default 0); the generic desktop save system ignores it. |
Returns: { slot_name: string, user_index: int, exists: bool, save_path?: string, file_size?: int, modified_iso?: string, modified_ticks?: int, error?: string }
list_save_games¶
Read-only
List the save slots the platform's save system knows for a user index: on desktop, the .sav files at the root of Saved/SaveGames, each with slot_name and, when that file exists, file_path and file_size. Use it to find slot names for load_game, get_save_game_slot_info (one slot, with its modified time) or delete_save_game; save_game writes a slot. A save system can also keep a slot as a FOLDER of .sav files, which is not a slot here: those folders are reported apart in slot_folders (count does not include them), so an empty list is only proof of no save when slot_folders is empty too. Read-only and idempotent; no PIE needed. No saves at all gives count 0, not an error.
| Parameter | Type | Required | Description |
|---|---|---|---|
user_index |
integer | no | Optional user index, default 0. Passed to the platform's save system; the generic desktop one keeps every user's slots in one folder, so there it changes nothing. |
offset |
integer | no | Index of the first save_games entry returned, counted from 0 (default 0). Read the next page at the reply's next_offset. |
limit |
integer | no | Most entries returned per call, 1..1000 (default 100). |
Returns: { user_index: int, save_directory: string, save_games: [{ slot_name, file_path?, file_size? }] (sorted by slot_name, paged with offset/limit), count: int (entries in this page), total: int, offset: int, limit: int, returned: int, truncated: bool, next_offset: int|null, slot_folders: [{ folder, sav_files }] (subfolders of save_directory holding .sav files, searched recursively) }
load_game¶
Read-only
Load the SaveGame stored in a slot with LoadGameFromSlot and report the transient object: save_game_instance, save_game_class and save_game_path. success is false when the slot is empty or unreadable, or holds a class other than save_game_class; get_save_game_slot_info (exists) tells missing from corrupt. It only reads: the slot file is not changed and the object is transient. Write a slot with save_game.
| Parameter | Type | Required | Description |
|---|---|---|---|
slot_name |
string | yes | Save slot name to load from |
user_index |
integer | no | Platform user index for the save system; default 0 (the generic desktop save system ignores it) |
save_game_class |
string | no | Optional SaveGame subclass the slot is expected to hold. A slot file records its own class and is rebuilt as that; when the loaded object is not this class (or a child of it) the load is reported as failed. An unknown class name is an error. |
Returns: { slot_name: string, user_index: int, success: bool, save_game_instance: string, save_game_class: string, save_game_path: string, expected_class?: string, error: string }
load_game_from_memory¶
Read-only
Deserialize a SaveGame from a base64 blob (the memory_base64 of save_game_to_memory) with LoadGameFromMemory; returns the transient object save_game_instance, save_game_class and save_game_path. Invalid base64 is an error; success is false when the blob is corrupt, truncated or from another SaveGame class. It only reads: nothing is written to disk and the object is transient. Make a blob with save_game_to_memory; to read a slot file use load_game.
| Parameter | Type | Required | Description |
|---|---|---|---|
memory_base64 |
string | yes | Base64 text of a serialized SaveGame, as returned in memory_base64 by save_game_to_memory |
Returns: { success: bool, memory_size: int, save_game_instance: string, save_game_class: string, save_game_path: string, error: string }
restore_actor_state¶
Destructive Idempotent
Restore the transform + properties a previous serialize_actor_state wrote, addressed by the SAME key it was saved under. Idempotent: restoring twice in a row re-applies the same values both times. It restores only what was captured -- if serialize_actor_state was called without property_names, this puts back the transform and nothing else.
| Parameter | Type | Required | Description |
|---|---|---|---|
actor_name_or_stable_key |
string | yes | Required. The stable_key used at serialize time (or the actor_name, when no explicit stable_key was passed to serialize_actor_state). The actor to restore ONTO is then resolved from the actor_name stored inside the saved payload, looked up in the current world. |
Returns: { restored: bool, properties_restored: [string], transform_restored: bool }
save_game¶
Destructive
Write a NEW SaveGame object holding its class defaults, of save_game_class (default UMCPSaveGame), to a slot with SaveGameToSlot, overwriting whatever the slot held. It captures no live game or level state, so use it to create or reset a slot, e.g. to test a load path. On desktop the file is Saved/SaveGames/<slot>.sav. Read it back with load_game, check it with get_save_game_slot_info or list_save_games, delete it with delete_save_game; for bytes that never touch disk use save_game_to_memory. The old file is not backed up and there is no undo step. An unknown, non-SaveGame or abstract class is an error and nothing is written; success is false, with an error, when the engine refuses the write.
| Parameter | Type | Required | Description |
|---|---|---|---|
slot_name |
string | yes | Save slot name, e.g. "Slot1"; on desktop it is the file name Saved/SaveGames/<slot_name>.sav. list_save_games shows the slots that exist |
user_index |
integer | no | Platform user index for the save system; default 0 (the generic desktop save system ignores it) |
save_game_class |
string | no | Name of a loaded, concrete USaveGame subclass, e.g. "MySaveGame", or "BP_MySave_C" for a Blueprint one already loaded (found with FindFirstObject, never loaded from disk); default UMCPSaveGame |
Returns: { slot_name: string, user_index: int, success: bool, message: string }
save_game_to_memory¶
Read-only
Serialize a NEW SaveGame object holding its class defaults, of save_game_class (default UMCPSaveGame), with SaveGameToMemory and return the bytes as memory_base64 with memory_size. Despite the save verb it writes nothing: no slot, file or asset, and the object is transient and dropped. Use it to see a SaveGame class's default serialized form, or to get a blob for load_game_from_memory, which round-trips it; to write a slot on disk use save_game. No live game state is captured. An unknown, non-SaveGame or abstract class is an error; success is false, with an error and no memory_base64, when the engine fails to serialize.
| Parameter | Type | Required | Description |
|---|---|---|---|
save_game_class |
string | no | Name of a loaded, concrete USaveGame subclass, e.g. "MySaveGame", or "BP_MySave_C" for a Blueprint one already loaded (found with FindFirstObject, never loaded from disk); default UMCPSaveGame |
Returns: { success: bool, save_game_class: string, memory_size: int, memory_base64: string }
serialize_actor_state¶
Destructive Idempotent
Save an actor's transform plus an EXPLICIT set of properties into a SaveGame slot, keyed by an identity YOU choose (stable_key, defaulting to actor_name). Nothing is captured implicitly: name the properties you want in property_names or you get the transform and only the transform. Idempotent -- re-serializing the same key overwrites that slot, it never duplicates. Pair with restore_actor_state, which takes the same key.
| Parameter | Type | Required | Description |
|---|---|---|---|
actor_name |
string | yes | Required. Object name or editor label of the actor to serialize (resolved via mcp_common::FindActorByName). |
stable_key |
string | no | Optional. Identity used as the persistence key; defaults to actor_name. The caller owns this key on purpose: AActor::GetActorGuid() is editor-only and not documented as stable across level reloads, so no GUID key is auto-generated for you. |
property_names |
array | no | Optional array of UPROPERTY names to capture in addition to the transform. If omitted, ONLY the transform is saved -- it never silently saves "everything" via CPF_SaveGame, which no native property here sets and which, on a Blueprint variable, depends on whether that Blueprint ticked the SaveGame checkbox (get_blueprint_variable_detailed_info reports it): a filter this command cannot assume for you. |
Returns: { slot_id: string, saved: bool, property_count: int }