[SOLVED] Compile store data aswell

I have captured the movements of a sprite as if it were the controllable character in my game. So when running the game that sprite moves just like I moved it before, just like the game running a gameplay without playing. These stored data are the X and Y coordinates for each frame in various very long arrays, among other things, multiplied by timedelta to skip the data that is necessary. To capture the movement I set fixed framerate to capture absolutely all frames. So far everything works perfect. The problem is that when compiling the game I lose the store files of the movement of that sprite. Is there any solution? It has taken me a long time to create this system to start a different one from scratch

To confirm, you have the data points in a file, but when you compile, the file isn’t included in the packaged game? If so, then maybe some of those involved in the more technical side of GDevelop may be able to help.

But for a work around, I’d look at converting the files to JSON, and copy paste their contents into text objects on the scene. Then, at the start of the scene, convert the text from JSON into the various array variables (and then delete the text object). Yes, a bit hacky, and require manual intervention, but it should get the job done.

1 Like

I am using internal storage not file system for this. I have no idea where that data is, roaming/gdevelop? roaming/game, the project itself?

Ah, that gets a bit trickier. Here’s a link to how you can view the internal storage. As to how to get it out and into the compiled game, I don’t think there’s an easy way (though I’d love to be proven wrong in this case). I’ll see if I can figure out a relatively simple way, if no one else has any thoughts…

1 Like

As a general heads up, storage is designed for saving user data/configs after the game is compiled or in Preview (basically, per install). It is not meant as a way to store data for cross-install data.

I don’t believe there will be a way to compile that data, although you could always load the storage into a variable while running the debugger, then save the variable info to a file? Not sure you will be able to get it into your game code any way other than manually, though.

2 Likes

That seems the best method at the mo given the restriction in GDevelop.

1 Like

I am going to create a code to save the internal storage into an external file. Create a big string variable in the code. Maybe I can use string functions to extract snippets of text and convert into numbers again.

Look into converting the variable structure into JSON - it’ll be easier (and a lot, lot less fiddly) to pull out the numbers.

1 Like

You mean copy the array from debug to clipboard and after paste in another place. I don’t know convert to JSON. Please I need instructions to make it, I don’t know anything about it.

No, more like JSONify the structure and assign it to the text object, then copy it from there.


There are actions in GDevelop to JSONify a variable:


And there are actions to convert JSON to variable:

image

2 Likes

I got it. It has been difficult for me to understand what JSON files consist of and how they work, but modifying the original code has been very easy to do thanks to great gdevelop functions.

Just converting an array of text to an array of numbers has been a bit more complicated. I wonder if there is a simpler way than looping iterations.

Thank you!

If the text are all numbers, there’s no need to convert. Use VariableString on a variable to get the string version of the value, and use Variable on the same variable to get the number version of the value:

So say _myVariable is 15,.Then VariableString(_myVariable) returns “15”, and Variable(_myVariable) returns 15.

1 Like

Amazing!, thanks again!