How to save many of object in one time

hi guys i have a problem…i have this character and lot of crate how can i save all of the crate in one time (with write and read action) and thanks

Can you please explain what you mean by ‘save’…?

1 Like

with storage system…

[edit] I modified my initial response to use an array of structures, and not just a structure.

Use a “For each object Crate” loop, write the crate details you want to a scene array of structures, and write the JSON string version of the array to storage.

To read, load the JSON string, create an array of structures out of it and iterate through all the structures to get the crate’s details for the create crate object action.

1 Like

i will try this…thanks

aaa can you make a exemple please hhh I did not understand you XD and ty

Here’s an example that works :

Left mouse click to create a crate object at the mouse pointer, and “s” to save the crate positions. When you start the app, it’ll load the last saved details and create the crate objects.

Remember JSON is a string, and represents the structure. When GDevelop parses the JSON string, it recreated the structure, with all the child node names as they were when they were saved. Which is why we can use Child.X & Child.Y; they are the names used when the details were saved (from SingleCrateDetail.X and SingleCrateDetail.Y).

1 Like

thanks you very much and 1 more question what is do the for every child in all crate detail and can you give me the exemple and thanks :3 <3

Sorry, I don’t understand your question. Do you want an explanation on how to get the “For every child” event? If so, click on this icon image in the editor, and select “For each child variable…”


the question is what is do the “For each child variable…”

It’s a control event that loops through each child element of an array or a structure.

So say, for example, your AllCrateDetails array had 5 elements (for 5 crates). GDevelop would then put each element, one at a time, into the variable Child, which you can access until the next iteration of the loop. In this case, the variable Child would have a particular crate’s X and Y position (that was retrieved from storage).