0 votes

Hello people,

I would like to know how do I load a saved array?

var achievements = [0,0,1,0,1]

I tried using getvar like this: achievements = getvar ()
but what did not work. :\
the array gets null, always when I try to load the game
Can someone help me solve this little problem? :)

asked Jan 9 in Engine by ismaelgame7 (128 points)

2 Answers

0 votes
Best answer

I hope this helps someone who is having problems / difficulty doing this:

var file = File.new()
var savePath = "user://Save.json"
var safeScene = "Level1-1"
var score = 0
var achievements = [0,0,1,0,1]
var canMusic = true

#Save & Load
func saveGame():
    var dict = {


func loadGame():
    if file.file_exists(savePath):
        var tmp_data = file.get_as_text()

        var dict = {}

        safeScene = dict["safeScene"]
        score = dict["score"]
        achievements= dict["achievements"]
        canMusic = dict["canMusic"]
answered Jan 11 by ismaelgame7 (128 points)
0 votes

You can not help me?
I'm trying to make a system of achievements using a simple array.
The problem is that I'm getting this error:


I was wondering if I'm doing something wrong at the moment of saving or loading the game.


please anyone know how to solve this?

answered Jan 10 by ismaelgame7 (128 points)

Saving an array should work the way you're doing it. Have you checked that the other variables are being loaded properly? The saveGame() function is missing a save.close() command although I'm not sure if it makes any difference.

Hello, maybe this is it, I forgot to add save.close ()
Well, there is no way to check, since I have reformulated the functions using JSON.
Thank you anyway!!!!!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.