0 votes

Okay, so, this is my script now:
extends Node

const SAVEPATH = "res://savegame.json"

Escreve o arquivo de save
func savegame():
#nicializa o arquivo //create the file
var file = File.new()
game.sav", File.WRITE)

Salva o arquivo //save the file
file.storeline(tojson(Playervariables.save())) //playervariables.save is a function that returns a library

func loadgame():
# Open existing file
var file = File.new()
game.sav", File.READ)

Get the data
var data = {}
data = parsejson(file.getline())

So, now i want to get the content in this data library and put into my Playervariables class attributes
PS: Player
variables is a singleton with, duh, my player status

in Engine by (14 points)

1 Answer

0 votes

-Make a "Playervariables.load(data)" function and call it with the data from the file.
-Do in Playervariables.load what you did in Playervariables.save, but in reverse. Assuming that in the Playervariables.save you took the variables' values and store them in the data, in the Playervariables.load, set the variables from the data.

by (104 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.