Game crashes when loading the game.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BE-Never Games
:warning: Old Version Published before Godot 3 was released.

Hey Godoters,

so basically, i have a little bit of a problem and i wanted to ask here, if anyone else encounters this before i open an issue on Github.
For some reason, when i load my game, it crashes the game, there are no error messages and i have no idea why this happens, especially because it worked before and it just suddenly started to happen, when i load my game. i followed the official documentation for loading and saving my game.
Does anyone else here has this problem?

Did you save and load game data with json format?

volzhs | 2016-08-19 02:47

Yes, exactly.

BE-Never Games | 2016-08-19 07:56

:bust_in_silhouette: Reply From: linuxfree

try remove a file in ~/.godot if you using linux
your script new have function to create a new savegame file check that before.

i think will work

Well, Í am on Windows, but unfortunately, that doesn’t solve it.
thanks for answering though.

BE-Never Games | 2016-08-18 19:31

:bust_in_silhouette: Reply From: volzhs

There is a similar issue with parsing json format.

I suggest you to use store_var and get_var for saving and loading with binary format which is much simpler and I believe it faster, if you don’t have any particular reason to use json format.

var data = {"key1":123, "key2":"abc"}
var DATA_PATH = "user://save.data"

func save_data():
	var f = File.new()
	f.open(DATA_PATH, File.WRITE)
	f.store_var(data)
	f.close()

func load_data():
	var f = File.new()
	if f.file_exists(DATA_PATH):
		f.open(DATA_PATH, File.READ)
		data = f.get_var()
		f.close()

Great idea, but unfortunately, that still doesn’t solve it. I am beginning to think, that it doesn’t have anything to do with the loading itself, but instead another script isn’t happy with loading the game. It could also be a bug inside Godot, but I am not so sure about that. It is just weird that this occurs, since it worked fine before.
But anyway, thanks for the answer, i will play around a bit and see if I can finde the problem.

BE-Never Games | 2016-08-19 10:46

:bust_in_silhouette: Reply From: BE-Never Games

Alright I solved the issue now, the input function of a different node caused this problem, but it works again.
Thanks to everyone who answered!