0 votes

I'm trying to save my game using .save files. When loading data back in I can't access any of the saved objects' properties or methods. It throws an "Invalid get index "x" on base Reference()
Any advice ?
Code here :

func saveData():
var data = globals.game_data 

var dir = Directory.new()
if !dir.dir_exists(SAVE_DIR):
    dir.make_dir(SAVE_DIR)

var file = File.new()
var error = file.open(save_path, File.WRITE)
if error == OK:
    file.store_var(data, true)
    file.close()

func loadData():
var file = File.new()
if file.file_exists(save_path):
    var error = file.open(save_path, File.READ)
    if error == OK:
        globals.game_data = file.get_var(true)
        file.close()
in Engine by (17 points)

Please log in or register to answer this question.

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.