- Edited
there doesn't seem to be a dedicated method for this in the FileAccess docs and File.store_var(dictionary)
didn't work.
for context, im making a minecraft like game, and each chunk uses a BlockDictionary to store the blocks location and type in the world:
BlockDict[blockposition] = {"BlockName" : "test" , "VisibleFaces" : [0,0,0,0,0,0]}
so the chunk uses the position of the block to determine its visible faces and name and then spawns it at said location. after all blocks spawn,the chunk runs a function and creates a single collision shape that contains all blocks. in order to save the chunk, naturally i need to save the BlockDict of that chunk. now i tried using the RescourceSaver to do this by creating a ChunkData Class as a rescource, but calling CD = ResourceLoader.load(Savepath).duplicate(true)
for every chunk significantly reduced chunk generation speed. so i then gave the world a WorldData class and stored the CD of each chunk in that and then saved the WorldData instead. this helped the game by only calling load and save once, BUUT, when i walked around a bit and had more chunks generated, Calling ResourceSaver.save(Wd, Savepath)
Crashed the game, and when it did not crash, it would take more than a few minutes to save and the file size would exceed 50 megabytes, which is not ideal.
i need a way to either store the WorldData in one file without crashing the game and creating a ridiculously big file, or store the ChunkData for each chunk separately, without it causing much lag when loading and saving during runtime.
im pretty sure Json files wont solve the issue since they store the files as strings so its not any better than rescourcesaver. but im stumped in finding a way to use binary serializing for a dictionary, because how can i tell it which key corresponds with what blockname and visible face array? do i have to make a separate file for each item in the dictionary?
this is the last thing i need to finish my world generator, which i have been working on for the past 2 months.
thank you and have a good day.
Edit: File.store_var(dictionary)
does create a file, but there is no way to retrieve it as a dictionary and File.get_as_string()
returns null. i have no idea what to do with it.