Save and load position didn't work

Hi, I have a problem with save and load it didn’t work in my game, I want to save player position, so I have load button in the mainmenu and the save button in the pausedmenu, and this is my screen shoot for the events…

and also I added read the value at the begging of the scene.

You’re writing to PositionX, and reading from positionX. The ‘P’ isn’t capitalised. GDevelop is case sensitive.

1 Like

Hi, I fixed that but still not working

A few checks you can make :

  1. Check if there anything written in storage (use ctrl + shift + i, select the Application tab and click on Local storage > file://) You should see the saved values and storage area.

  2. If there is, check that you are reading and writing a value and not a text (double click on the read and write actions to confirm this)

  3. Make sure the variables you are reading into are scene variables. Globals won’t work

1 Like

Hi, I checked there is a saved value but the load didn’t work

And what about checks 2 & 3?

sorry for delay, yes I checked its a value and I am trying to save x and y position.

So it saves a value to storage. So a few more questions:

  1. How are you checking that the value isn’t being read properly?
  2. Have you checked the value of the variables PlayerX and PlayerY?
  3. Do you set the player’s position using these two variables?

Can you provide a screen shot of where you use the variables?

Hi, these my screen shots

You haven’t answered my questions - the screen shots don’t show how you use the variables (PriestX and PriestY) nor do they show where are you setting the position of Priest using the variables.

You show the events reading the values and setting 2 variables with them, but nowhere can I see that the Priest’s position has been changed using those 2 variables.

The other 3 questions to answer are :

Keep in mind these questions weren’t just asked for the sake of it. It’s to work out where the problem might be. There are a few possible reasons, and we want to eliminate as many of them until we work out where the problem lies.

Hi, thank you for continue helping, as for the first question i checked the save value through ctrl + shift + i
when i press save the x and y values change…

but when I press load nothing happen, is there a way to inspect the read values through debugger or I must see it in the same way I see the save value?

and for the second question i didnt understand exactly what do you mean do you mean the scene variable PriestX=0 and PriestY=0 in the variable list?

for the third question i guess yes i use it here is the screen shot

What I mean is how do you know the variables PriestX and PriestY have values. You can determine this a number of ways :

  • place a temporary text box on the screen and output the variable values to that.
  • run debug mode, and inspect the variables
  • in the event that reads to values in add the action to write it to console. Then run in debug and check the value that’s written out to the console area.

The other thing to do is make sure the read action is executed. In the event where the values are read in, add a temporary event to change the colour (tint) of one of the on-screen objects (say the red-heads to “0;0;255”) . If it changes colour, then you know the actions are being hit. If it doesn’t change colour, then the event conditions are not being met.

You can inspect the priest object and check it’s position, and ensure it’s the same as the saved values after you clicked load.

BTW, are you doing anything else whe the load button has been pressed? You’re not reloading the scene by any chance?