system
December 18, 2021, 12:52pm
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
Ktotoetoia
hello, im making 2d game, and i dont know how can i save bool variable, i save float var like this
var file = File.new()
line_text = file.get_line()
file.open(“res://scenes/save.txt”, file.WRITE)
file.store_float(int(coins))
system
December 18, 2021, 1:50pm
2
Reply From:
timothybrentwood
You are looking for var2str()
and str2var()
. Search for “Saving data that exists solely in Godot” for an example of how to use them from GDQuest’s website:
Thanks, but i didnt understanded how it works, i changed variable from bool to float
0 = false
1 = true
Ktotoetoia | 2021-12-19 12:18
I did it one more time and it works, thanks
Ktotoetoia | 2021-12-19 12:28
nAiL
January 23, 2024, 6:47pm
3
In Godot4 you can do this:
var file = FileAccess.open(“user://save.dat”, FileAccess.WRITE)
file.store_var(your_bool_var_name)
To load use:
var file = FileAccess.open(“user://save.dat”, FileAccess.READ)
your_bool_var_name = file.get_var(your_bool_var_name)