0 votes

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()
linetext = file.getline()
file.open("res://scenes/save.txt", file.WRITE)
file.store_float(int(coins))

Godot version 3.4 opengl 2
in Engine by (99 points)

1 Answer

+1 vote
Best answer

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:
https://www.gdquest.com/tutorial/godot/best-practices/save-game-formats/

by (3,870 points)
selected by

Thanks, but i didnt understanded how it works, i changed variable from bool to float
0 = false
1 = true

I did it one more time and it works, thanks

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.