This is my code:
extends Node
const SAVE_FILE:String="save_file.save"
var g_data:Dictionary={}
var current_save:int=0
func _ready() -> void:
load_data()
func save_data():
var file:FileAccess=FileAccess.open(SAVE_FILE, FileAccess.WRITE)
file.store_var(g_data)
file.close()
func load_data():
if not FileAccess.file_exists(SAVE_FILE):
g_data = {
"num_of_saves": 0
}
var file=FileAccess.open(SAVE_FILE, FileAccess.READ)
g_data = file.get_var()
file.close()
This is the error I am getting from this code:
Attempt to call function 'get_var' in base 'null instance' on a null instance.