extends SceneTree func _init(): #print("Testing SaveManager...") # Instantiate Global manually var global_script = load("res://Autoload/Global.gd") var global_instance = global_script.new() # Manually call _ready because we are not adding it to the scene tree global_instance._ready() # Check what is in Global.Owniverse #print("Global.Owniverse: ", global_instance.Owniverse) #print("Type of datetime: ", typeof(global_instance.Owniverse.datetime)) # Mock Global in SaveManager? SaveManager uses "Global" name. # In GDScript, "Global" refers to the Autoload name. # If we just instantiate SaveManager, it will fail to find "Global" if it's not in the tree or global scope. # Workaround: I'll just copy the logic I want to test. var data = global_instance.Owniverse #print("Data to save: ", data) var filename = "user://test_save_check.dat" var password = "test" var file = FileAccess.open_encrypted_with_pass(filename, FileAccess.WRITE, password) if file == null: print("Error opening file for write: ", FileAccess.get_open_error()) quit(1) return #print("Saving...") file.store_var(data) file.close() #print("Loading...") file = FileAccess.open_encrypted_with_pass(filename, FileAccess.READ, password) if file == null: printerr("Error opening file for read") quit(1) return var loaded_data = file.get_var() #print("Loaded data: ", loaded_data) if str(data) == str(loaded_data): print("SUCCESS: Data matches.") else: printerr("FAILURE: Data mismatch.") print("Original: ", data) print("Loaded: ", loaded_data) quit()