Please tell me an approximate template of how to save a lot of data in godot. I've watched a bunch of videos about it, but everywhere they show mostly only the ways of saving itself, and not how to implement it into your game that need to save many of data. For example, I can write a script in the main node of the scene to save player data and load it using a function in the same script in the same node. But with the advent of a bunch of objects that also store their properties, there is such a problem that it is not possible to place it all correctly. Do I need to make some kind of global script with auto-loading, which will cause all nodes to save and load functions, or what? I am very interested in solving this problem. [I hope it is written clearly, despite the fact that I used a translator to write it in English]
One approach is to have an autoload whose script has a Dictionary that contains the data you want to save and methods for saving and loading the data.
Since it's an autoload, the Dictionary and the methods are globally accessible.
Manysided Ok, thank you so much! So I will save all the values there as the game progresses and I will save it all there. But if I need to load, how do I initialize all the values back? Do I need to do this, for example, in a player's script, write a method for initializing variables that will be taken from the loaded global script and assigned to the player? Or can it be done in a more correct way?
Arrears how do I initialize all the values back?
It depends on your project.
In a current project, I load the saved data in the main script's _ready() method. There's some initialization that needs to be done before loading the data, and some initialization that depends on the loaded data and has to be done afterwards.
© 2022 - 2024 — McMap. All rights reserved.