viniciusgerevini / godot-clyde-dialogue

Clyde Dialogue Language Importer and interpreter for Godot.
MIT License
89 stars 11 forks source link

Restoring dialogue state from json (Bug?) #12

Closed jcandres closed 2 years ago

jcandres commented 2 years ago

I may be missing something, but I have found it impossible to restore dialogue data from a json file.

The problem is that Memory.gd uses numeric keys for its dictionaries, but those keys become strings once converted to json.

I hacked my way out of this simply by converting to strings the id arguments in every method in Memory.gd, for example:

func set_as_accessed(id):
    id = str(id) 
    _mem.access[id] = true

Now it works seamlessly when saving/loading from json -- but perhaps there's a better way of handling this.

viniciusgerevini commented 2 years ago

Totally a bug. I faced this problem with my game save files. The funny thing is that I've been using Clyde for almost a year and that has never happened to me with dialogues restore. Or maybe I just haven't noticed it, which is weird.

I believe there is no other way besides treating it as string inside the memory module. Thanks for reporting this and for all the feedback. That's extremely valuable.