[SOLVED] Storing object variables (object created while running)

How do I…

Im creating a evolution sim game, and i want to store body part variables to recognize to wich parts is connected by an ID.

What is the expected result

Object “square” has in its variables/data that it has an eye, tow mouths and another shape conected, this shape need to be created with two ears and a mouth. but the game doesnt know that info of the second shape, since, I dont know how or in what form to store that it has two ears and a mouth + the ID that shares with the first shape to connect them.
So i need to store the second shape body parts and ID variables to connect to the body, and this shapes could end up creating more shapes that need to be stored as well since it can “mutate”

It sounds interesting. What part do you need help with? Setting up the objects or saving/loading them from storage?

When saving variables it helps if the variables are in a structure. That way you can save all of the variables at once. You could have a structure with other structures or arrays.

It’s made more difficult because you can’t use for each child with object variables. It would be so much easier if you could.

This is the closest I’ve done. IDK if it would help. I don’t think the game previews still work but and github project should be. The first level is easy but

With more details, you’ll get some help. I’m guessing that currently there’s just not enough details to help you. People here work better with smaller chunks. This is a bit intimidating.

1 Like

I need help in saving and loading an object variables that was created in the scene.
example in context of my game;
base genes: the game starts with an elephant. the front with a long nose and big body.

the elephant then pass its genes.

passing Genes: First the game needs to make the elephant all over again, and it checks for the length of the nose and the size of the head. A wrong variable may make a rhinoceros or an anteater if it gets something wrong. so it needs to pass with precision.

(extra) mutating: now the elephant may want to make more than one, and it may be bigger or smaller by mutating, so it now has two different elephants, one bigger and one smaller.

Now for that to happen I need to store the “genes”, so the progenitor has almost similar genes. and so on.

I would understand if it isn’t possible for Gdevelop 5.

Forgot to add, but the reason to store for each object is because there would be more than one creature with distinct genes.

This is one way. Others will probably recommend other ways.

I know nothing about the gene aspect. This is similar to the spaceship example. It uses 2 buttons, 1 to save and 1 to load. It uses an object group. The objects have al structure variable named Data. It saves the objects x, y and animation. These can be added to if you want to add say width. You would need to add the names to the structures and add actions. I used 2 structures to hold the values but the same structure could probably be used. I like separate names. Both structures was identical.

Events

Scene variables

Object variables

1 Like

I followed it but its not loading, i dont know if its saving either

Object


Scene


Compare this section.

To my example

Yours seems to be reversed and the 2nd variable has an extra child. It should just be the variable name.

The structure (ObjectStruct) needs be added to the array (SaveData) to create an array of structures.

That’s the only difference that I see.

1 Like

THANK YOU SO MUCH, ITS FIXED.

1 Like