ResourceSaver.save() doesn't save the values of any variables

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By even_nuller

Calling ResourceSaver.save() doesn’t save the values of any variables from my custom resource at all. How do I know this? because when trying to print a variable from the loaded resource, it returns null. And yes the variables do have a value before saving the resource.

Here is my custom resource script:

extends Resource
class_name GlobalSaver

const SAVE_PATH = "user://saved_settings.tres"

var bomb_plant_code
var bomb_defuse_code
var bomb_plant_time
var bomb_defuse_time
var random_code_plant_length
var random_code_defuse_length
var bomb_expload_time
var reset_plant_or_defuse_length

func save_to_disk() -> void:
	for v in Global.DEFAULT_VARS.keys():
		print('{0} : {1}'.format([v, get(v)]))
	
	ResourceSaver.save(SAVE_PATH, self)
	print(load(SAVE_PATH).bomb_plant_code)

func load_from_disk() -> Resource:
	if ResourceLoader.exists(SAVE_PATH):
		return load(SAVE_PATH)
	return null
:bust_in_silhouette: Reply From: exuin

I think they need to be export variables to be saved.

thanks this just helped me after like an hour of debugging

sir doge | 2023-05-26 11:38