#How to load dictionary

1 messages · Page 1 of 1 (latest)

rain holly
#

I have a dictionary file that looks like this, and i want a dictionary in my game to turn into this file.

#

The keys to the dictionary are random, they arent always a, b, and/or c

#

And so are the values

placid otter
#

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

rain holly
#

Thank you so much!

#

I`ll see if i can get that to work

rain holly
#

For some reason, it`s not working @placid otter

wicked forge
#

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())

rain holly
#

Fixed. Here`s final code

wicked forge
#

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://

rain holly
#

Already a comment about that

wicked forge
#

OPS LoL...sorry, I completely ignored it 🙂

placid otter
rain holly