0 votes

I'm trying to write and read large Dictionaries to files. It looks to me a simple file.get_var() blocks the thread, so I cannot update the UI (to show a progress bar).

If I'm writing the Dictionary to a file as a JSON string, I can read back the data by lines: I enable the _process method, read a couple of lines, concatenate them into a string buffer, then exit the _process method and at its end I update the progress bar. On the next occasion I read a couple of lines again, and this keeps on repeating until I've read all the remaining lines from the file, then I disable the _process method, and finally parse the complete string as JSON.

This approach is fine, but instead of the JSON format I'd like to use binary serialization. However, I don't understand how I could use the get_var() function in this case (by building for example an array of bytes via looped file.get_32() calls in a _process loop, periodially updating the progress bar and finally feeding that array of bytes into get_var). The "Binary serialization API" doc mentions that the PacketPeer class also implements the get_var method, but I can't figure out how I could actually use it.

Could someone show me an example?

in Engine by (20 points)
edited by

Hm, maybe bytes2var?

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.