#Saving

1 messages · Page 1 of 1 (latest)

fathom crow
#

I have several checkbuttons and need their toggle states to persist after closing the app, without explicitly having a save/load button. What's the easiest way to achieve this?

feral knoll
# fathom crow I have several checkbuttons and need their toggle states to persist after closin...

Save to disk: https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html

And instead of an explicit "save button", just make a save() function and call it after every checkbutton change, etc.

fathom crow
#

Does that work if i'm making something specifically for android?

#

res://saving_test.gd:3 - Parse Error: Function "get_tree()" not found in base self.

Also I'm getting this error

feral knoll
fathom crow
#

`Thanks.

#

So for making the dictionary, what would I put as the value? Would I make a toggled signal, then put a var in there?

feral knoll
#

the value of the whatever thing you are storing..

#

if its a check/unchecked button, that sounds like a bool to me

fathom crow
#

but how do i pass the bool into the save function

feral knoll
#

You could create a dictionary with your values (like a bunch of bools) in there

#

check the saving tutorial, the first part is Serializing

#

going from a collection of variables into a single dictionary

#

instead of stuff like damage and attack, you'll be storing your bools

fathom crow
#
        
    var save_dict = {
        "filename" : get_scene_file_path(),
        "parent" : get_parent().get_path(),
        "alda1" : _on_savetest_toggled(1),
    }
    return save_dict
    ```
... is this right
feral knoll
#

If those are the things you want to save, yes

fathom crow
#

But with it being _on_savetest_toggled(1) wouldn't it just save it as always being on then instead of on/off

feral knoll
#

I have no idea what your _on_savetest_toggled() is, I figured it's just a test function.

Normally when it comes to vars & bools, you'd have something like this: var my_bool : bool = false
And later somekind of function to set it to the actual value instead of the default false, something like this: my_bool = #whatever your function/code/logic is

And then in your saving dictionary, you can do:
"amazing" : my_bool