Blank corruption

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

I have a save and load system in my game. It is working as intended, and when I wake up, the file is completely blank if you run it in the notepad. And it is not blank like a blank pages, if you highlight it, you can see that there is a character but is corrupted. I dont know why this happen, can someone ??

Can you post the code for saving the file? Probably the file is not saved in a text format.

Bubu | 2021-04-19 01:41

I have 2 different save system, the one is the system itself which handles settings, menu etc. and that is called collector and the other one is normal save/load which handle game progress.

func save(Name : String):
var g = game_save.new()
g.Project = $Project.Project
g.Practice = $Project.Practice
g.History = $Project.History
g.Output = $Project.Output
print(Main_Collector)
add_to_collector(Name)
Save_collector("Main")
ResourceSaver.save(file_directory + Name + ".tres", g)

Load

func Load(Name: String):
var directory = Directory.new()
if !directory.file_exists("user://" + Name + ".tres"):
	return false
var data = load("user://" + Name + ".tres")
$Project.Project = data.Project
$Project.Practice = data.Practice
$Project.History = data.History
$Project.Output = data.Output

Collector shit

func Save_collector(type):
if type == "Main":
	var C = Collector.new()
	C.Main = Main_Collector
	print(C.Main)
	ResourceSaver.save("user://MainCollector.tres",C)
elif type == "History":
	pass
func Load_collector(type):
if type == "Main":
	var d = Directory.new()
	if !d.file_exists("user://MainCollector.tres"):
		return false
	var Data = load("user://MainCollector.tres")

Mrpaolosarino | 2021-04-19 01:52

I don’t use collectors so I’m not really good at spotting the problem here.

Bubu | 2021-04-19 01:56

I will dig into my save and load code and see if there are differences in your code.

Bubu | 2021-04-19 13:11