[Solved] it was a typo with “Unlock” being “Unlcok”
Also it might have also had to do with spaces in variable names instead of underscores.
Along with some other error I found later where some sprites and sounds that were deleted in my project folder were referenced in other events but did not exist anymore. These additional factors may have also contributed to “breaking” the write and read events.
I have a functioning system to display locked and unlocked levels on level selection seen.
Everything works with global variables.
Then when I looked at some tutorials to save the global variables I used the right and read storage events to save the values of the global variables so that levels will be unlocked when the game is closed and reopened.
As far as I can tell I followed the correct steps but the game does not save the values of the global variables when the game is closed.
Please take a look at these screenshots and tell me where there are mistakes in the right and read storage events.
I tested the game by exporting it to .apk and .exe formats.
Then I beat level 1 in the game and closed the game.
Before the game was closed the level 2 unlocked button appears as it should, but when reopened it doesn’t.
Yes I did write in and read from values, which in this case is the number 2
Other information that might be useful is the write action is in the level 1 scene and the read action is in the level select scene which has the locked and unlocked level buttons. Though I don’t think that has an effect on the storage not working here.
Lastly here is the local storage file key the screenshot couldn’t capture it all even when expanded.
So I also copied it to paste here
Are you talking about the 1st screenshot showing the global variable?
Because Level_2_Status is just underlined since my mouse was left on it when I took the screenshot.
I use the global variable Level_Unlcok_Progression to control the unlock status of each Level Status global variable. In this case when Level_Unlcok_Progression is 2 it changes the value of Level_2_Status 2 to unlock the level 2.
Does this condition ever get met? Can you add an action to this event, to change the tint of Market_Price to red (“255;0;0”). If the object Market_Price doesn’t turn red, then it hasn’t saved to storage, and indications are there’s something wrong with the collision.
We have progress now. You are right about the collision having an issue it did not turn red and that was because “Market_Price” is a light so it didn’t turn red and I suppose didn’t trigger the write action as well since it was not a sprite.
I then went to the console and saw there are multiple GDJS keys now and some have what appear to be the correct values. I took screenshots of them all in order from top to bottom of the list. I think the ones that have no value are the read actions not reading anything and the ones with the appropriate value of 2 are the write action performing without error.
After restarting my computer and GDevelop twice I still got those same results shown above with the keys for previews, and testing with an exported .exe.
The good news is level 2 does get unlocked but when the game is closed and reopened this is not saved and level 2 is locked again. That is another reason why I think at least the write action works now and the read action may be working, because if the game is not closed the write value in storage is red to change the variables to unlock level 2.
The typo was indeed the problem and the collision with “Marke_Price” the light actually did work to trigger the write action.
I even tested this in preview and .exe. The result was fully functional. However when I tried it as .apk on an android phone it did not work. This was after another 2 restarts of my PC and re-exporting along with even re-installing GDevelop.
I tried the same set of events to unlock level 3 after level 2 is beat and back to nothing working. The console shows only shows the exact same keys as the previous screenshots. So level 2 storage is being written but nothing to do with level 3 is occurring in the console.
So I decided to make the simplest rendition of my storage and variables by starting a new project.
This resulted in what looks like a successful write in the console but no desired outcome of saving a yellow block that turns red in the top left corner.
So here it is.
A green block collides with a red block which is supposed to create a yellow block that is then tinted red in the top left corner. This result does not occur and it is definitely not saved when the preview and/or .exe tests are closed and reopened.