[Solved] Save levels using global variable

Hello people, this is my fist game and I am learning . I made most of the game on my own including the level - lock , un-lock . The only problem I am having is saving the un-locked levels . I have seen a lot of tutorial’s and notes but still I am not able to save the state . I have used global variables to make the level system, for eg if the player collides with a checkpoint then value of a global variable is created and in level select if the particular value of the global variable matches then the level get’s unlocked . I have to use these to save un-locked levels. As I am a beginner please try to explain to me in an easy manner .

this is the completion of lvl 1.

how are you mean “save”? to the local storage? ro to file?

BTW there is an error on the screenshot. you can’t execute actions in the current scene after you leave it. and you don’t need to create two event if they conditions are exactly the same. just add all actions in one event. and make sure the scene scange action always will be the last action in the event!

I want the levels to be saved for eg lvl 2 is completed and the game is closed then the next day or when the game is restarted the lvl which was unlocked previous day should stay un locked and I am not getting the error in the screen shot can you explain it in detail .

the explanation in in the comment…

than you should decide how are you want to save. it to the local storage, or in to a file. you will find help both.

I am a beginner , I don’t know which one to use though I saw that in storage there was a read and write option along with JSON files. I would prefer read and write options which I tried but didn’t work .

hi, I’m new too, but my backup system is working, so I hope it can help you

When my level ends i write a scene variable, you can give the name you want :

I suck to explain, I hope you will understand.

-Then on my menu (where it has my levels) I start by reading my end of level value
-I then say that if my variable = 1 then I change the animation of the icon of my level for me 0 is red and 1 is green
-me new game buton is for reset the value
-Lvl 1 i have set just basic condition for launch the level
-finaly for unlock the lvl 2 , he need the animation to be 1 so green for me, to be able to click above and start the level

my explanation is terrible so look the pics, you can ignore (new game) :

ah and I forgot to say, when you need to read a variable, he say scene variable, I didn’t try with global variables but maybe that’s why your trying doesn’t work

2 Likes

OK, I understood but scene variables are for a particular scene so how can you read a scene variable from another scene(end of a particular lvl) from the lvl select scene . Is it true that ,when a scene variable is saved (written) then it can be loaded(read) in another scene ? If yes then it can work .

Here’s the Save/Load example project…
https://editor.gdevelop-app.com/?project=example://save-load

Also there is a video tutorial about Save/Load which you can find in GDevelop by going to the Storage section there >

I have seen it , didn’t help .

Did you see the save/load example project?

Yes, I just want to know how to save unlocked levels , the tutorial is different .

You could modify that save/load project to your needs but maybe that’s beyond your capability right now. Try this one…

Ok, I watched the tutorial and then I used write text option and it Worked:tada: . I used the exitance of a group option and it was sufficient . TTTTTanx

What about when u used score as global variable…and unlock levels with global variable score…what should i do…it dosent save the game at all & also unlocked level…please give me some suggestion…