[Solved] Help Needed To Proof Read My Storage Events

[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.

Make sure your read and write are both numbers, and not one is text and the other is number.

Also, this part here, swap the delete and create action. Otherwise you delete the object and then refer to it’s position :


How have you determined this?

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



Also I switched the delete and create actions like you pointed out.

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.

It could well be the spaces in the storage name that’s throwing it. Replace them with underscores and test it out in preview.

If that still doesn’t work, press ctrl + shift + i (either in the GDevelop editor, or when you run the game in preview or from exe).

Click on the console tab - are there any error messages?

Then click on the applications tab, expand Local Storage and click on file:\. There should be a GDJS_<…> key. Can you screen shot all the keys and values?


Correct, that won’t affect it. Storage doesn’t care where you’re accessing it from. Check that there is data being written using the crtl + shift + i technique detailed above.

MrMen your efforts to help are much appreciated.

After adding underscores to the write and read there is no effect after testing again.

Then here are the console messages

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
“{”_version":1,"_name":“Powerup 38”,"_locked":[],“sampleRate”:44100,“attack”:0,“sustain”:0.15,“sustainPunch”:100,“decay”:0.38,“tremoloDepth”:0,“tremoloFrequency”:10,“frequency”:1200,“frequencySweep”:1700,“frequencyDeltaSweep”:100,“repeatFrequency”:0,“frequencyJump1Onset”:33,“frequencyJump1Amount”:0,“frequencyJump2Onset”:66,“frequencyJump2Amount”:0,“harmonics”:0,“harmonicsFalloff”:0.5,“waveform”:“whistle”,“interpolateNoise”:true,“vibratoDepth”:0,“vibratoFrequency”:10,“squareDuty”:15,“squareDutySweep”:-20,“flangerOffset”:0,“flangerOffsetSweep”:0,“bitCrush”:16,“bitCrushSweep”:0,“lowPassCutoff”:22050,“lowPassCutoffSweep”:0,“highPassCutoff”:0,“highPassCutoffSweep”:0,“compression”:1,“normalization”:true,“amplification”:100}"

General Heads up: You should never use spaces in Variable, objects, or attribute names. It can lead to poor (if not outright broken) behavior.

It could also break your storage load/unload situation you’re seeing here.

Edit:
Also note: you’re only looking at the very first key in your local storage. There are numerous keys below it, your divider line is just too high. You can drag that downwards to see more Keys.

Ok there is the right key

Thanks for the input SIlver-Streak
I replaced spaces with underscores but I still have the same situation

That being empty indicates your storage is never getting saved, so something is going weird with your save events (maybe also your load events, but definitely your save events, at least)

My thoughts exactly Silver-Streak

You should also note that you’re looking at a completely different storage than your screenshots.

In your storage screenshot, you’re looking at “Level 2 status”. but your events all reference “Level_Unlcok_Progression” (you really should fix that typo)

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.

No, in your screenshot here.

You are not writing to that storage in any of your events, so it isn’t the storage you should be looking at.

OK thanks for that note.
However it is the same key value for this key too.

Can you close down GDevelop and restart it? Someone else had issues with writing to storage and restarting seemed to sort it out.

MrMen your continued help is appreciated.
I restarted my computer along with GDevelop several times and ran a preview a few times as well.
The recurring result was as follows:

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.

1 Like

Thanks for another reply MrMen

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.

So I made a sprite called “Market_Price_Core” and it changed red with the tint action you suggested so the collision condition is working.

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.

Also here is my level 1 event for beating level 1 and saving the data with the changes

Then here is the level select group of events that are still the same and haven’t been changed since we haven’t found anything new to change yet.

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.

First screen shot is writing to “…Unlock…”. The second screen is reading from “…Unlcok…”. FIx the typo in the read, and it should work.

Good news and bad news.

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.