Godot Version
4.6.2 Stable
Question
How do I set it up so that when the user presses a button, a save data location is created and the save data is stored, so that when the user loads back into the software, it continues from where they were?
#Just to kind of give anyone an idea...
#Again, no clue what to do, this is just to give you an idea for what I'm trying to do.
extends Button
func _save_data(save location?)
func _on_ready()
load save_data
depends on how your game is set up.
Some games use json, others use methods that work for their other assorted needs.
Without a way to KNOW how you want to store data—or how you read data and apply it moreso—
Its really hard to say HOW to do this, how do you WANT to do this?
Whatever way takes up the least amount of space, and is easiest for the user. And also, not needed, but preferably, easy for me too.
In other words, you choose.
What i would personally do is make a simple json file with a save data object,
and simply make a function that writes all equipment, items, magic, etc. and then a simple entry for story progression, story dialog, cutscenes, and quests, etc. just be based off of a variable that is written at the same time the json entry is, save location and status effects in the same way… but thats how i would do it generally speaking, and this may be of no use to you depending on what kind of game you are making.
*this is adding to my previous responses
I always keep all data related to the game state in one large Dictionary object. Then you just save this object to a file using the store_var function and restore the state using get_var. It’s simple and fast. Maybe I’ll make a short video about it.
4 Likes
So for my game I just used a json with a save path wihich I could then read and save through the Gamemanager
Thank you all for your suggestions. But is using a ConfigFile a good method? Because I’ve heard that’s beginner friendly. But again, I’m brutally inexperienced in creating save games. I’m willing to take awhile for this, but I do need to figure this out within the next 2 weeks. Again, thank you everyone.
If anyone can share code, that would be helpful. I can also record a video of what I’m trying to do and post and link that to YouTube. Would you guys prefer that?
There’s an entire guide, with code examples in the documentation. I’m not sure what else you need.
The guide even specifically told you that config files are NOT a good fit for save files.
1 Like
Question, when would you release that guide?
I already did in my book: Godot 4: Advanced Game Development
Chapter 6, section Automatic save and load.
As for the video, it might take some time because I am currently recording some other stuff.
Okay. Thank you, I’ll look into that.