Save and load system Part 2


Make sure you named your Variables “Scene” not “scene”

Ok, I’m pretty sure I did EXATLY what you did.

On every event sheet of your scenes you have to add this at the end of your code

Tell me if it worked!

Did it work on your computer?

I didn’t try it. I have no scenes and no sprites. I just made an example.

ok. I am still checking for errors in my external events page.

Hi. It didn’t work. I tried a bunch of different ways but nothing. I’ll keep trying though!

If your events work fine in one specific scene, you cut and paste them into external events, then insert the Link event where your events were, and it’ll work just the same.
Until they work fine in one scene, there’s no need to bother with external events. Focus on the events.

If you want further help, we need to know exactly what the issue is.
“Tried a bunch of things” is not a good description of what you did.
Likewise, “and nothing” is not a good description of the issue/outcome.

Good luck :slight_smile:

Yes, It does work in one scene. Just copying and pasting them into external events and linking it to other scenes is all there is to it?

Because I tried that too and This shows up when I click the load button:

Don’t mind the red cursor, that’s not part of the game. I am guessing because the game doesn’t know what scene to spawn the player in when the load button is clicked. Help please?

You just answered your own question, so the solution is to also save the name of the scene and when you load the game then get the name of the last saved scene to load.

I have modified the save-load example, included 3 scenes and when you click the save button you also save the name of the scene and when you click the load button, it is going to load the last saved scene.

You can download the modified example from the bottom of this list (save-load-multiple-scene), hope it helps:

Maybe it would be helpful if you guys tried my game. Maybe you can see whats wrong. I totally agree with @ddabrahim.

Just, how do I make the last saved scene show when the load button is clicked? Like, how do I get the name of the last saved scene and automatically load?

I just linked you a working example with comments every single event. In case you don’t understand how the example works maybe the problem is you don’t understand how the storage events works, in that case read this:Redirecting...

1 Like

Yes, I understand how to save things for just one scene. [I think that’s a pretty cool feature to GDevelop :slight_smile:] But I know I can’t put the same saving events that I use for one scene into another scene. That’s where it gets tricky. Here are the saving events I have for a scene that totally works:

I copied that from the example that you gave me. With a few changes to suit my game. Then, I tried to create external events and linked it to another scene. But that didn’t work.

Look at your code:
You are just writting the position of player, not the scene you are at.

1 Like

There is an action that says change the scene to_____________. In that blank can I type GlobalVariable(_______) or Variable(________)? So that the variable changes value according to the last saved scene and the Scene changes according to that Value! Would that work? That would solve everything.

You did not copy the part related to saving scene name.
So the important bits are:

  1. Scene variable called “savedSceneName” added in the variable editor in scene properties, why a scene variable in the editor is explained in the guide I linked
  2. the action to write the current scene name in to storage when you click save
  3. when you click load, check if current scene name exist in storage then load it in to the scene variable and go to that scene by getting the scene name from the variable:

So you need to work with the storage, variables and expressions here, you may want to get familiar with this 3 topics first if you still don’t understand how it works.
You can find more info here: Redirecting...

Good luck :+1:

1 Like

Thanks! :slight_smile: