Saving and loading large data from table files

Hello and good afternoon,
I am struggling with saving and loading some data in defold’s table files…
the issue is that apparently my data is too large for it, iam attempting to save texture data and then later load this table and create the texture dynamically… (no i cant put the data in the game as it needs to be downloaded from a server accordingly to the level the player decides to download, and it only downloads the level he chooses from a list he also gets from the server…)
I am being able to get the data from the server and save it just fine when the texture is something pretty small…like 100x100px but its failing to save any table above 524280 bytes (like half a mb)…
is there any way i can make the files bigger? each level is going to be a lot larger than half a mb…could be up to like 20…
or if anyone got any suggestions~ feel free to tell me~

You shouldn’t use sys.save and sys.load for large amounts of data such as images. You should instead use the io.* functions. Use io.open to get a file handle and then io.write and io.close.

2 Likes

thanks, I did that~ now its working perfectly, for some reason i thought it was wrong to use io functions when using defold LOL
:confounded:

1 Like

Nope, nothing wrong with using the io.* functions. As long as you use sys.get_save_file to get a path that is guaranteed to be read and writable on all platforms.

1 Like

@britzl sys.get_save_file may create a directory when you call it, like for example if i give it a directory that doesnt exists, it will attempt to create one…
is there any way to reverse this with just defold? removing a directory created by it? or would i need to use extensions? *i remember seeing a file management extension somehwere…but i dont wanna throw it into the project just for 1 line of code…

You can use os.remove() to delete files and on most operating systems (not windows) also folders. For folders on windows you could use os.execute and run rmdir. Or as you said, use the Defold-LFS extension.