# Custom Saving/Loading

It is quite easy to expand upon the existing save/load system, thanks to our [Save & Load Manager](/components-managers/player-specific-components/save-load-manager.md) and the power of **Instanced Structs!**

Lets demonstrate this with a few examples.

### Example 1.0 - Saving a Custom Property

For this example, we're going to add a new variable to our **Character** blueprint **(B\_Soulslike\_Character).** You can also add it to any component you want.

<figure><img src="/files/wnphjcoBz1JZNEw0tmCz" alt=""><figcaption></figcaption></figure>

Next, we'll add some example events to alter/view its value:

<figure><img src="/files/uBlmQd7MgTmvAtGz5gAf" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/rjdOzYyu3bbOCd6bI1hI" alt=""><figcaption></figcaption></figure>

Now to save this variable, all we need to do is trigger the **RequestAddToSaveData()** message in our **Player Controller (PC\_SoulslikeFramework):**

<figure><img src="/files/FgJw53cScIXaSeaNPkLN" alt=""><figcaption></figcaption></figure>

This message has 2 inputs. It might look a bit overwhelming at hindsight. However it provides a great amount of modularity when it gets to saving/loading data:

1. **Save Tag (Gameplay Tag):** Tag used for tracking save entry. Can be used to find data by tag and/or update/remove save entry data.
2. **Data\[] (Instanced Struct):** The actual data that is going to be saved/loaded.

In our case, we'll create an array which contains a single element - the value of our new property "MyVariable". This will update our save data and trigger an autosave whenever we change this value. We should also make the saving part a custom event if we want to call it from anywhere else.

Finally, there are 2 methods in [AC\_SaveLoadManager ](/components-managers/player-specific-components/save-load-manager.md)that we need to adjust:

1. **SerializeDataForSaving():** Serializes a specific data by tag and adds it to the final save data.

<figure><img src="/files/Eg4Qf2AEjvPIjJyNCzoS" alt=""><figcaption><p>Rough example - the cast can be avoided.</p></figcaption></figure>

2. **SerializeAllDataForSaving():** Serializes all possible data and sets it to the final save data.

<figure><img src="/files/AfMbBqIExLgWc1lU5GV4" alt=""><figcaption><p>Rough example - the cast can be avoided.</p></figcaption></figure>

You're all set! Now our new property will get saved whenever it's value has changed. Additionally, it will also get saved whenever we bulk-save data (specifically on quits/crashes etc).

<figure><img src="/files/0IG8kOX6Eatws4KQ3yg6" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
The reason it takes a few extra steps to save a simple property in Soulslike Framework is due to the save system being designed for handling more complex sorts of data.

You can always check out the existing saving/loading functionality for more information.
{% endhint %}

### Example 1.1 - Loading our Custom Property

Loading the saved data is as easy as this:

<figure><img src="/files/AvhBhO9dHmcTppolHTsZ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/fq1tgfBdrMGBvwXFL3j2" alt=""><figcaption><p>The decimal difference is related to formatting.</p></figcaption></figure>

### Example 2.0 - Saving Custom Actor(s)

For this example, we're going to create an actor which adjusts its scale when player overlaps its trigger. Then we'll save its "overlapped" state and new scale.

Lets start by creating a new actor and setting it up accordingly:

<figure><img src="/files/TmDkdRvCXC7eZrNVRJ3K" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/FbOlmzPy99My5Ypq0N1X" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/hLinq7bslLQ2cVatIxae" alt=""><figcaption></figcaption></figure>

Next, we'll need a new **Struct** to keep track of the 3 properties this actor has:

1. **Id (GUID):** the unique identifier of the actor (important)
2. **Scale (Vector):** the 3d scale of the actor
3. **HasBeenOverlapped (Bool):** the state of the actor

<figure><img src="/files/rPfu86aasAKc9gccnDRZ" alt=""><figcaption></figcaption></figure>

And now, when the timeline for scaling up is finished, we can request to update the save data with the new entry:

<figure><img src="/files/WWDh88URBWC5WVqgYvxz" alt=""><figcaption></figcaption></figure>

Finally, ensure that the actor instance you want to save in your world/level has a valid GUID:

<figure><img src="/files/KU9rwuyeyuqSxVF1GdMQ" alt=""><figcaption></figcaption></figure>

That's it! Now we're saving this actor.

### Example 2.1 - Loading our Custom Actor(s)

To load, we just need to adjust our Event BeginPlay slightly and bind to [AC\_SaveLoadManager](/components-managers/player-specific-components/save-load-manager.md)'s **OnDataLoaded()** delegate:

<figure><img src="/files/KfGYw5JU94NpRbo20Ntx" alt=""><figcaption></figcaption></figure>

That's basically it. Now when you play, you'll notice that this actor now saves its properties!

<figure><img src="/files/vnULr5VrQfDGddyjmrbx" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://soulslike-framework.isik.vip/extending-functionality/custom-saving-loading.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
