[SOLVED] Save/Load system not Saving/Loading

I am having an odd situation, I need to have the code at the top of the image run when the scene starts. Also for current debug reasons the lines below work with pressing 1 2 and 3 on the keyboard and change the values saved in the storage to set the players class and max hp appropriately. For some reason, the code only saves and loads the values when I set the load function to require a keypress. What I believe is going on is that because of the constant loading of the storage it prevents it from saving, however when I try to put it to only load at the start of the scene it still doesn’t work. Does anyone have any idea how to solve this Issue? I will update if I find a solution.

(warning i dont know for sure im just taking a wild guess)

i think you may be overloading the system by making it constantly save? so you might wanna set the saving on an auto save timer?

Maybe you should make sure that the values exist before reading them. You’ll find conditions for storage and for variables.
And add a Trigger once if it only needs to execute once.

I have absolutely no Idea why I didn’t think about trying that. I will try that right now and let you know what happens.

That got the load function to work, but saving still doesn’t save. I’m going to see what happens when I tell it to write a global variable in storage rather than just a number and see if that helps any.

I cannot get the game to save anything at all. I even tried deleting the PlayerStats storage and having it tell me when It does it and it then tells me correctly but when I close and reopen the game it loads anyway even though it shouldn’t have anything to load from.

Can you provide a screen shot of the code that saves and loads? Otherwise there’s a bit of guesswork to what the events look like.

Here is the current code and how it looks, pressing one two and three on the keyboard are supposed to save but does not, and I know the game is loading because its creating the character as if its saved 2 in “Class” of “PlayerStats” before, it wouldn’t be creating anything if it wasn’t. I did even go back and make sure that none of the values it had to load was a 0 to make sure nothing was just popping up at the start of the scene.

I even went back into the code again to remove everything that wasn’t just saving and loading, and it still loading as if the value of “Class” is 2, no matter what I do. I have even checked my other external events to make sure nothing was setting the variable or storage to 3. Here is how the code looks only dealing with the important saving and loading.

I also just tried changing the name of the storage to just “Player” instead of “PlayerStats” and it is no longer loading “Class” as a variable of 2 but its also still not saving anything.

I have even tried changing the keys used to save to z,x, and c for the time being. I’ve tried saving a static number, ive tried saving a scene variable or a global variable. I’ve tried constant loading, constant saving, autosave timer, auto load timer, literally everything. Has anyone got any ideas, or is safe to call this a bug on gdevelop’s part?

Did you try to use underscores naming instead of Camel case.

Look some of my Main Globals to use Storage


I have this as an external event so when i need to use Storage in the GameScene just link to this event sheet.
As you can see every entry has a condition to check if NO exists in Storage and other condition to set the values if already exists in Storage.

When I need to include this events in the GameScene I just add a link.

Other thing I notice is that you have an empty condition that use Load storage “PlayerStatus” in memory, and that condition has no Trigger Once, I think is Loading all the time.
Try to add Begin of the Scene or Trigger Once in that condition.

I entirely rewrote the code in an external event in the same way as your example, and deleted the old code and made sure to link it. It is properly loading but is only saving until I close the preview. When I reopen the preview it acts like it never saved at all. Am I missing some setting in the engine somewhere?

Idk much about actuall code, but could this have semething to do with it?

The thing is that you need to run the Storage load at the very first scene if you use my method, but rewrite the events and remove the user interaction.

Just check if the values exists if not then create.
Like in my screenshots.

Look at my game logic.

Splash Scene
Link to MainGlobals so here at the begin of the game after the GDevelop 5 loading percentage reach 100%

All the Storage data of my game is setup on this very first scene, and without the user interact.
In your case the Debug Group must be changed to something like this


Without the Trigger Once and the Keyboard user interaction.

Plus you can remove the Load storage at the begin of the scene because you’re linking this events in your GameScene so the Lead storage “Stats” in memory is no longer needed.

The only problem with removing the player Input is my game lets you choose between three classes at the start of the game, but If I can get everything else to work I am fine with doing a Gungeon style, Pick your player kind of thing.

SOLVED. I never closed the storage when I was done with it. I tried to fix this since Thursday, and it took me rewriting the code for the 3rd time to notice it. Ill mark this as solved thank you for your help.

SOLVED!
I feel insanely dumb right now. I’ve spent 4 days trying to get this to work and Its all because I never closed the Storage. It took me rewriting the entire block of code 3 times just to read “make sure you close the storage”. I feel really dumb thank yall for your help. I’ll mark this as solved.

There is nothing wrong with this console log, all these yellowish logs are simple warnings because the dev inspector can’t load a file used by devs in the GDevelop team. These warnings have no impact to users.

Anyone interested in there is an example for save and load., each line is explained.

Anda wiki page about it too.

I’m glad you found the solution!