# Load/Save System

This Module adds two new Actions that can be used with loading a Saved Game.

| Action Name                       | Description                                                     |
| --------------------------------- | --------------------------------------------------------------- |
| **Current Profile from Variable** | Allows the setting of the Player Profile from a Global Variable |
| **Delete All Profiles**           | Deletes all current Player profiles                             |

{% hint style="danger" %}
These Actions can only be used with Game Creator Version 1.1.6 or Higher.
{% endhint %}

There are also two new scripts, one for uGUI text and one forTMP text. The scripts are called DropDownSaves and DropDownSavesTMP respectively. They are atteched to the UI Dropdown with the DropDown Elements added to the Save Slot, the Text Label added to the Label Slot, and the name of a Global Number Variable added to the Target Variable slot (in our example this is titled Load-Slot).

![](https://1680659799-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LauqCzuMnmk33t__Yp5%2F-M0vG_zsTjB86hec7uUR%2F-M0vJ_vi3fC0KncNPOgQ%2FL1.jpeg?alt=media\&token=2aea021b-2514-4482-8229-ee4263661534)

After this has been added to the DropDown element, we have added the On Value Change by dragging in the Dropdown Element, and selecting the dropdown\_indexchanged method.&#x20;

![](https://1680659799-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LauqCzuMnmk33t__Yp5%2F-M0vG_zsTjB86hec7uUR%2F-M0vJwYdNlIf59G2KQmE%2FL2.jpeg?alt=media\&token=e3ec092b-b34d-44d1-bd58-f9b49169b485)

{% hint style="warning" %}
The above points are only of use for those wishing to build their own Load/Saved system
{% endhint %}

The DropDown element should now works as designed. Any Saved Games will be displayed in the list in the order of most recent at the top, and on selection, the name is placed in the Label and the corresponding Profile number for this saved game is placed in the Load-Slot Varaible.&#x20;

When the Load Button is clicked, the profile is set to the selected one, and the game is loaded from this profile.

![](https://1680659799-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LauqCzuMnmk33t__Yp5%2F-M0vKDlxP3zvW3BfBYxh%2F-M0vLK_2kOupoZ8C40lG%2FL3.jpeg?alt=media\&token=851a5424-dc92-4527-9508-101fcc2503e0)

There are two other points to consider. Firstly, when saving a game, you should configure your save Actions as shown in the example.

![](https://1680659799-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LauqCzuMnmk33t__Yp5%2F-M0vKDlxP3zvW3BfBYxh%2F-M0vLyDacKJyp12bT1O_%2FL4.jpeg?alt=media\&token=af7ee8ae-721e-4c78-b6b4-3ffd2540f218)

We have added a Global Number Variable called Save-Slots. We use this to keep track of saved games as to not overwrite saved games from the last play session. As shown above, before you save a game, add 1 to the Save-Slots variable, then set the current Profile from this variable using the new Action that is included with UI Components.  Finally, save the game using the current profile.&#x20;

The second point is how to clear or delete saved games (there are a maximum of 99 profile slots). You will note that we have added a GC Toggle checkbox to the DropDown panel.

![](https://1680659799-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LauqCzuMnmk33t__Yp5%2F-M0vKDlxP3zvW3BfBYxh%2F-M0vNxTD9S4npL7mHTKm%2FL5.jpeg?alt=media\&token=c9fb4692-1803-4af6-808e-a37fddd20ba9)

When this is checked, the toggle will change a Global Bool Variable. We have called this Clear-Save-Slots.&#x20;

![](https://1680659799-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LauqCzuMnmk33t__Yp5%2F-M0vKDlxP3zvW3BfBYxh%2F-M0vOem4W1RjspCyPaGF%2FL7.jpeg?alt=media\&token=71e888e8-3251-48a6-998c-5948a09709e2)

Then we add the following GC Condition to check this Variable and if it is set, to Delete all saved game profiles as show below.

![](https://1680659799-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LauqCzuMnmk33t__Yp5%2F-M0vKDlxP3zvW3BfBYxh%2F-M0vP0UG8sgECYNDmesz%2FL6.jpeg?alt=media\&token=b198c282-7df7-4c7e-b936-b75f189f6495)

{% hint style="danger" %}
This should only be done AFTER the current game has been loaded or a New Game has been selected. We have added the above Condition to the Main Scene.
{% endhint %}
