0 votes

I have looked at many tutorials on saving/loading but can't quite get my head around it. Also, my game is a 2D RPG so there are many factors to save (health, level, hair colour, hair type, stamina, mana etc). Could someone please provide some script which could help me or possibly explain the process more simply?

in Engine by (292 points)

1 Answer

+1 vote

I think it would be a nice tutorial for you. Try seeing from Save File Data.
In it first the data which needs to be stored is converted into a dictionary. And then that dictionary is converted into a json file by using

var file = File.new()
    file.open("user://savegame.json", File.WRITE)
    var json = to_json(data)
    file.store_line(json)
    file.close()

Where data is a dictionary which contains all the information which needs to be stored.
Reading the file is hard to explain here so it would be nice if you see up the tutorial. Just see how the player's data is saved.

https://www.davidepesce.com/2020/07/31/godot-tutorial-19-start-menu-changing-scene-saving-loading-game/

by (872 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.