[SOLVED] Save and Load Global Variables in Windows App

Thanks! I’ll give this a closer look later and get back to you on how it worked out for me!

Gotcha.

I added the external event link to those other scenes, but no window appeared that I’m seeing. I’m using the desktop version of GDevelop if that’s perhaps the problem.

Also, I kind of asked this before but I just want to be certain, the various scene variables involved in this process are all laid out on only one level right now. Do those same scene variables need to be added to every other level for the load process to work effectively?

Just to illustrate my point, the image to left shows the variables in the level that lets you save & load progress, and the right image shows what all the other levels’ scene variables look like. This variable ‘SAVEDEMO’ isn’t even being used anymore, so they are essentially all blank.

the last time I did this, the window is still pop-up. so I don’t know what is the problem. I’m using the desktop version too. may be something changed.

if you dont use this vaeiables (as scene variables) for anything else, you don’t have to create them. you read on the Wiki, when you write value in a non-existent variable, GDevelop will create it to you. so the external event will work without adding these by hand. (if this was the question. sorry I can’t speak English)

So I’m still getting weird/no results in my main game. I decided to start over with something much more basic, but even then, the process as I understand it, doesn’t seem to be doing anything.

Here is literally the whole game and all of it’s associated variables.

This image shows the main page, consisting of three different squares. If you click one, it changes color. There is a red one, a blue one, and a yellow one. Pressing ‘f’ will take you to the page that lets you save or load the game.

Here is the level where you save and load by clicking on one of the two squares. A key will take you back to the prior scene if needed.

This is the external event page. It is connected to the ‘COLORSAVE’ scene that both the prior levels have used in their external events.

This is the ‘COLORSAVE’ scene. It just references back to the external event page. It probably doesn’t need to be on it’s own like this. But I tried the game without it and there was no difference anyway.

These are the scene variables as they appear in every level, including the ‘COLORSAVE’ scene. Apparently you don’t have to include matching scene variables in every level, but I did it anyway to be safe.

Here are the global variables in their natural ‘0’ state. When you click a square to change it’s color, the variable should increase by 1. This value of 1 is what’s supposed to be saved and loaded, but simply isn’t.

I’m going nuts trying to figure this system out, so hopefully this is all the data necessary to figure out what I’m doing so wrong.

I think you need to move the link event to the top.
So check the assign of Scene variables and Global variables as Text, the difference on Globals ans Scenes variables for float/int and Text types is iimportant, and since you are declaring the Globals and Scene as Text.
The way to retrieve/store the data correctly is treating the variables as Text.

Here Global RED

Note the difference is VariableString(SOMESTRING)

Here Scene RED

In some other scene event sheet the assign

1 Like

Do the global variables have to have text instead of values for the saves and loads to properly operate?

I ask because my actual game relies more on digits (zeroes becoming ones and adding or subtracting from there for different results), so changing so many global variable values could be tricky.

Global or Scene variables could be treated as String or numbers. just make sure when you check in debugger or in Dev console which type is defined for your variables.
Plus is a good practice to name variables lowercase, or camelcase. For instace I use g_ for Globals s_ for Scene variables.


Here a projecto to show how to assign to a Global variable the value of an Scene variable
Download

I confirm. This manner of identify the names of variables can make more easier the find of bugs.

Should anyone in the future encounter this same problem, I did find a couple example levels that demonstrate roughly what I’m looking for HERE and HERE.