[Solved] Save/Load Linked Objects?

Hello and goood evening!

In my topdown RPG, everytime I create a Treetrunk, I create the treetop as 2nd object along, and link both.
So I can animate them individually and also if the Tree gets chopped, to delete the correct top at the same time as the trunk.

So now to my blockade - how do I safe and load this?
I safe the Tree with an array variable, and do I loop to put it all together when loading:



So yes, there is no creation of the treetop and setup for the correct animation of the top… maybe someone could give me an idea. BIG THANKS!

Not sure I understand exactly but Can you assign an instance id to each when you create them and save them so you can identify and put back together on load?

Use an array of structures to store the tree details (you don’t need to create the children of this variable, I just did it to show you how it was structured):

I would use events similar to the following to save the data:

And something like this to load and create the trees:


MrMen, you beat me to it. My version was very similar. The main difference is I used a Boolean named “hasTop” to decide whether to add a top and then I used a point on the tree bottom to add a top.

Note: I used the new variable syntax, so the variables need to be added to the variable screen to be used without the variable() part.
source: (click green [code] and [download zip])

right click to add a tree, drag the tree by dragging the bottom, Click save, click load

1 Like

Sorry for late reply, Christmas and so on :wink:
But big thanks to MrMen - this helps alot.

I did not rebiuld it exactly like that but yes, for every instance of the loaded tree (by an array), I recreate a new tree top and linked it, change the animation, zorder and so on: