0 votes

Okay, so I tried to go with a tutorial on load and save function and once I wrote the code, it showed that there is expected end of statement (var).

var error : int ResourceSaver.save(savepath, savegame)

I couldn't make it work, unless I removed the " : " and " int "

in Engine by (16 points)

Does it work if you add an = between the variable and the ResourceSaver?

var error : int = ResourceSaver.save(save_path, save_game)

1 Answer

0 votes

If you just need to save a variable or a dictionary this works fine (using it in my projects)

Everything in the "save" dictionary will be saved to the file, call the load_data to load it.

var save = {}

func save_data():
    var file = File.new()

func load_data():
    var file = File.new()
    if not file.file_exists("user://save"):
        return false
    save = file.get_var()

check if the vaiable exist

func _ready():
    if not save.has("item"):
        save.item = {"worlds":{},"count":0}

or just set true

save.level_finished = true
by (198 points)
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.