Save the game and respawn from last level

You were very close before. The problems are highlighted in the red boxes:

If you want to reference a variabels or function, do not enclose it in quotes. “MySave” (in quotes) is literally the letters “M”, “y”, “S”, “a”, “v” and “e”. It is not the contents of the variable MySave, but a string made up of those lettters.

If you want the value in the variables, just use the variable name without quotes.

Here’s an example, where the variable is named MySaveTempSave. It’s in the convert JSON expression without quotes, and its value will get used:

This will get tedious if you have a large number of levels, and is more error prone:


As a tip, a simpler method that can be used for an unlimited number of levels is:




To get this, click the “Use an expression” button when selecting the scene:

@MrMen
Damn i did not spot that quotation marks
I hate dyslexia

Anyway if we are going for most simple approach i wanted to go with this
These events would be used to automatically take player to last level in which checkpoint was reached and load his position
Where 1st event should be in scene from which player is taken to last level
And 2nd and 3rd events should be placed in each levels scene events

@RoyTheLegend
Just be aware MySave.Level needs to be TEXT variable

ALSO
If i unlocked level 2 and reached it checkpoint i restart game i will spawn automatically in level 2 at its checkpoint
BUT if i would be able to go back to level 1 and reached its checkpoint
Then checkpoint save would be overwritten so next time i reset game i would not spawn in level 2 checkpoint but level 1 even so level 2 was unlocked

That is why i did ask how exactly your game work
So i can adjust it to it

Like can you go to previous levels
Should each level have its own checkpoint
Should it force player to go automatically to checkpoint? Maybe you would leave choice to player does he want to start from checkpoint or from beginning of level?

A LOT of things you may want to go with in your game i don’t know about so i did not know around what make whole logic

with the way i did i used save value not a text now when i try to make text it doesn’t work

i tried you technique to save i did the same you did but here i didn’t find “CurrentSceneName()”
5

thank u for the advice
look i think here only needs a child but i didn’t tried yet idk if will works
6
7

Look here are my global variables
Notice how Level is TEXT variable
And PosX is NUMBER variable

And look for PosX i can’t type CurrentSceneName()
I mean i can write it down but expression for it DO NOT EXIST for number variables

Now check this out
When i do the same for Level which is TEXT variable what do we have as 1st option?

You most likely did not change Level to be text variable

ugh why this is so hard and not working :frowning:


that’s what i did in main menu sheet, the button not works etheir with these events even if i added Change to scene level1

and here what i wrote in the levels events

Because your logic is incorrect. You have the change scene event as a subevent of the “At the beginning of the scene” event.

A sub event is processed or actioned only if the parent is actioned. The parent only actions once at the start of the scene, so the subevent is only processed once - when the scene starts.


If you want the player to move to the saved position, you first need to load the saved position from storage. You’ve done something similar earlier, loading present level from storage. Do the same in the “At the beginning of the scene” event with the saved position.

I started using gdevelop around 2 years ago
Since that time i NEVER see Keith giving me bad advices
Read it carefully and understand what you are doing
You are almost there


Still the button not working :((


you mean like this ?


guys thank you so much for everything i know I’m bad with the saving things i really appreciate your patience and your time I’m grateful for your answers, it’s okay if you don’t reply anymore, sorry for everything

Yes, because it’s a subevent of the “At the beginning of the scene event”. It won’t work because it’s only ever checked once, when the scene starts.

If you collapse a parent event (by clicking on the little triangle on its left), any events that are then rolled up and hidden are subevents of that parent event and will only get actioned if the parent event’s conditions are true.

And your loading of the saved values is occurring every game frame i.e all the time.

Fix these two issues by:

  1. Drag the cursor is on play into the event below it (the one with touch or button is down)
  2. Swap the storage events with the button events (dragging them is easiest)

The forum is here to help, don’t apologise if you don’t understand things straight off. We all have to strat at the beginning.


Where does Keith fit into this topic :stuck_out_tongue: ?

1 Like

that’s kind of you my friend <3


still no action after press button Play

That’s because those conditions include a beginning of scene. In order for the actions to be executed, all the conditions need to be true. Beginning of the scene is only true once, when the scene starts up. After that, it’s no longer true and so that whole event is not actioned again during the game.

What a shame
Sorry sory

Just so you are aware
I once told both of you
That each time i come here with a problem
Its either you or Keith who is helping me
And this is not a joke to tell you both apart
I was literally forced to read your nicknames
I could not remember which one of you have which avatar
So i always considered you two as one person
And to tell which one of you did actually help me i did need to read your nicknames
Even so each of you have VERY different avatar

I know nothing happened but i am very sorry
That needed to be funny in your eyes

1 Like

Roy when i was making my 1st project here
I wanted it so bad to be playable on phone
I was adding mobile controls basically virtual joystick
I was stuck with it for ONE WEEK because i wrote
Joystick.X() Joystick.X()
Instead of
Joystick.X() Joystick.Y()

ONE WEEK
So we all make mistakes no shame in that
Read my above message to read what i did to MR MEN
We can compete who looks more stupid now
And i offer that cause i very confident in my 1st place

Like MRMEN wrote
You have there at beginning of the scene

So you would need to hold cursor on play button and press it when scene starts for it to work
After that this even will never execute
So you need to remove at beginning of the scene from there

Now look on right
How you wanna change to two scenes at once?
Cause 1st you have
Change scene to tut1
Then
Change scene to MySave.Level

IT will go to tut but not to mysave
Cause tut1 is 1st action

So you would need to remove tut1 from there

Or maybe i am wrong?
Maybe it will switch to tut1 then to Level?
Either way action for tut1 there is NOT NEEDED

I did find it funny. I do the same with my kids. A lot.

1 Like

sorry i was busy the past couple days
you two guys are amazing i really wanted to be like you someday knowing everything and help the other who will do like me now lol


i removed the “tut1” scene but still the button not pressed but i have question how the game will begging if the first scene will be “MySave.Level” and this basically not a scene it just a save so because of that i put “tut1” also
i did added trigger once but was the same even if i remove it still the same

Join gdevelop discord
Type in search bar at top right corner ZeroX4 and search my messages by oldest

Or do the same here on forums
Check how i started
NO ONE came here smart we all were making stupid mistakes when we started
As time passes by default you learn stuff
Like if you been 100 times to some market
Even so you don’t buy everything you know where everything is or at least where to look for it
Same story here
So just stick around and sooner than you think you will bypass most users

1st of all look what you did
I did not spot it earlier so well shame on us both
Screenshot from this post

And your screenshot

If you can’t spot the difference look closely
In my condition and action
GROUP is always on left
And STORAGE is always on right (2nd thing that displays in condition/action)
My mistake it says EWF in condition and Storage in action but lets pretend they are the same
SO as you see ion action group 1st then storage
In condition group 1st then storage

So this is 1st thing you need to fix

Now let me explain what you have there on screenshot
In top event you check in conditions 2 things
1 - is scene just started
2 - does MySaveGroup exist in MySaveGroup

So this determines if anything is set to MySave.Level or not

Your button (2nd) event checks if you clicked on button
And if so change scene not to MySave.Level
BUT to whatever value MySave.Level have
For example it can be number variable and be set to 25 or 10 or 33
Or it can be text variable and have some text like sdadasd or xxxxxx or ugabuga
But in your case it is text variable which holds text of whatever name was of scene in which you lastly touched checkpoint

So it works perfectly now
BUUUUUT problem is
There is no scenario in your events for what if storage save does not exist in MySaveGroup?
That is why you should duplicate whole 2nd/bottom event
And add to it ORIGINAL same condition that checks if group exist in storage
And if so you change scene to MySave.Level
In DUPLICATE event you add same condition but inverted
And so it means save was NEVER created
So you change scene to your 1st level scene

And that is all

And again just so you understand
MySave.Level is just like a let’s say text file you named MyLevel
Now in that MyLevel.txt you write WHATEVER name of current scene is in which you touched checkpoint
Now when you start game you are not changing scene to MyLevel.txt
But to whatever is written INSIDE MyLevel.txt

This is how variables work like containers for informations/values

Now go do it

it worked kind of…
my levels started with " tut1 , tut2 , lvl1 , lvl2 and so on
when i pressed the button the lvl1 runs first, and if i run the tut1 and reach to checkpoint the tut2 skipped
also the player always fall from sky in the beginning of the level , in some levels he falls from middle of the screen and this happened when i pressed to button Play
i tried it from the mobile app the button Play still not pressed

One thing at a time
1st position
Look here

Gdevelop reads events from top to bottom
So you 1st change position of player then you load variable from which it should be loaded from
move load action above change position action
If that don’t help leave there load action but cut out change position action and create new event
Paste it to new event and add condition to it at beginning of scene but then invert this condition and check if that work