unreal.LocalPlayerSaveGame

class unreal.LocalPlayerSaveGame(outer: Object | None = None, name: Name | str = 'None')

Bases: SaveGame

Abstract subclass of USaveGame that provides utility functions that let you associate a Save Game object with a specific local player. These objects can also be loaded using the functions on GameplayStatics, but you would need to call functions like InitializeSaveGame manually. For simple games, it is fine to blueprint this class directly and add parameters and override functions in blueprint, but for complicated games you will want to subclass this in native code and set up proper versioning.

C++ Source:

  • Module: Engine

  • File: SaveGame.h

classmethod async_load_or_create_save_game_for_local_player(save_game_class, local_player_controller, slot_name, delegate) bool

Asynchronously loads a save game object in the specified slot for the local player, if this returns true the delegate will get called later. False means the load was never scheduled, otherwise it will create and initialize a new instance before calling the delegate if loading failed.

Parameters:
Return type:

bool

async_save_game_to_slot_for_local_player() bool

Asynchronously save to the slot and user index. This will return true if the save was requested, and errors should be handled by the HandlePostSave function after the save succeeds or fails

Return type:

bool

get_invalid_data_version() int32

Returns the invalid save data version, which means it has never been saved/loaded

Return type:

int32

get_latest_data_version() int32

Returns the latest save data version, this is used when the new data is saved

Return type:

int32

get_local_player_controller() PlayerController

Returns the local player controller this is associated with, this will be valid if it is ready to save

Return type:

PlayerController

get_platform_user_id() PlatformUserId

Returns the platform user to save to, based on Local Player by default

Return type:

PlatformUserId

get_platform_user_index() int32

Returns the user index to save to, based on Local Player by default

Return type:

int32

get_save_slot_name() str

Returns the save slot name to use

Return type:

str

get_saved_data_version() int32

Returns the game-specific version number this was last saved/loaded as

Return type:

int32

is_save_in_progress() bool

Returns true if a save is in progress

Return type:

bool

classmethod load_or_create_save_game_for_local_player(save_game_class, local_player_controller, slot_name) LocalPlayerSaveGame

Synchronously loads a save game object in the specified slot for the local player, stalling the main thread until it completes. This will return null for invalid parameters, but will create a new instance if the parameters are valid but loading fails.

Parameters:
Return type:

LocalPlayerSaveGame

on_post_load() None

Blueprint event called after loading, is not called for newly created saves

on_post_save(success) None

Blueprint event called after saving finishes with success/failure result

Parameters:

success (bool) –

on_pre_save() None

Blueprint event called before saving, do any game-specific fixup here

on_reset_to_default() None

Blueprint event called to reset all saved data to default, called when the load fails or manually

reset_to_default() None

Resets all saved data to default values, called when the load fails or manually

save_game_to_slot_for_local_player() bool

Synchronously save using the slot and user index, stalling the main thread until it completes. This will return true if the save was requested, and errors should be handled by the HandlePostSave function that will be called immediately.

Return type:

bool

was_last_save_successful() bool

Returns true if it has been saved at least once and the last save was successful

Return type:

bool

was_loaded() bool

Returns true if this was loaded from an existing save

Return type:

bool

was_save_requested() bool

Returns true if a save was ever requested, may still be in progress

Return type:

bool