#How to load dictionary
1 messages · Page 1 of 1 (latest)
The keys to the dictionary are random, they arent always a, b, and/or c
And so are the values
That looks like JSON, you can use JSON.parse_string(String) to get a Dictionary from it
If you want to then serialize that Dictionary using JSON, you can do JSON.stringify(Variant) to put it all on one line, or JSON.stringify(Variant, "\t") to add indents
For some reason, it`s not working @placid otter
I believe your error is because what's returned by FileAccess.open is a FileAccess object, and not the actual file contents
you can try ScoreKeeper.leaderboard = JSON.parse_string(file.get_as_text())
FileAccess.open -> https://docs.godotengine.org/en/stable/classes/class_fileaccess.html#class-fileaccess-method-open
FileAccess.get_as_text -> https://docs.godotengine.org/en/stable/classes/class_fileaccess.html#class-fileaccess-method-get-as-text
Inherits: RefCounted< Object Provides methods for file reading and writing operations. Description: This class can be used to permanently store data in the user device's file system and to read fro...
Fixed. Here`s final code
Now...I'd like to point out to something...I believe a file in res:// namespace wouldn't be able to be written on export (I can be wrong here). I'd advice some research but I believe a file you intend to write later should be in user://
Already a comment about that
OPS LoL...sorry, I completely ignored it 🙂
By the way, .bin files are normally raw binary, not plaintext. I suggest using .json or .save or some other file extension
Is there anything bad that can happen if i continue to use bin