serialize array[] into variable

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

hello people!

im tying to read a array and store it for adding content with .append

savegame.open("res://saveData/" + nombre + ".save", File.READ)
cadena = savegame.get_var()
savegame.close()

savegame.open("res://saveData/" + nombre + ".save", File.WRITE)
cadena.append(datos)

after declare cadena = savegame.get_var() I cant gett acces to ,append()
the debuf say “Invalid call. Nonexistent function ‘append’ in base ‘Nil’.”

even trying to get the items in te array give me the same debug report, I can add the savegame.get_var() wit append() but i need the array not a array inside other …

any idea?
thanks for all!

what is your problem exactly?
and save data should be under “user://” not “res://”

volzhs | 2017-11-07 03:34

after declare cadena = savegame.get_var() I cant gett acces to ,append()
the debuf say “Invalid call. Nonexistent function ‘append’ in base ‘Nil’.”

and thanks for the “user//” but im developing for android and i think it doest work, but i’ll check

shkur | 2017-11-07 07:33

if you are developing android game, you should use “user://” for saving something.
“res://” actually points inside apk that you can’t create, delete or modify.

get_var() can’t be executed properly because of error according to the error message.
it could be an empty file, or format doesn’t match.
how did you save .save file?

volzhs | 2017-11-07 11:54

I just fix it …
i feel so dumb , i was tying to store it in writing mode … -.-"

thanks for the help and sorry for being such a newbie

shkur | 2017-11-07 18:03

Mark as solved if it’s solved…

Kermer | 2017-11-18 12:14