Hello! I have a game that stores upgrades and their information in a DataTable. I also store the player’s current upgrade level in the DataTable and edit them as the game progresses (I’m not sure if this was the right idea after learning that DataTables are Read-only)
How do I save the current state of the DataTable? Right now I’m doing a workaround where I map all the player’s current upgrades and save them using “async save game to slot”, but I feel this will become tedious if I want to save multiple columns of data.
If I can’t save the DataTable itself, what are some other alternative ways I can store large numbers of structures? I’ve seen SQLite but I want to make sure there are no other simple alternatives before delving into it.
Thank you in advance!
DataTables are read-only. SaveGame objects are the correct way to store things. C++ makes it a lot easier.
Thank you for the reply! Come to think of it, using DataTable to store the player’s progress was a strutural error in itself…
As for storing methods, is it good to just save the TArray of the structure that I use in the DataTable in the SaveGame Object? Should I be worried about memory space / long save times?
Generally you should only save things that change. It does not make sense to save properties which are never going to change. Usually you will end up making a new struct for the savegame object in which you will store all the relevant dynamic data.
In general you should not worry about storage memory usage, but of course you can make optimizations. For example, an optimization Minecraft uses is to use a “seed” number to generate the base data for entire worlds. Instead of having to store that entire world, it can simply be regenerated from that one number. Any data that changes on top of the generated data is then saved, instead of the whole thing.
Long save times can be avoided by saving asynchronously, which means you don’t block the game while saving. Similar techniques can be used for loading.
Sorry for the late reply, and thank you so much for the detailed answer!
I did end up making an entirely new struct to save asynchronously and managed to save other items (resources) in that object as well, it works like a charm!
- Did you abandon DT code?
- Can you show how you ‘made new struct to save asynchronously and managed to save other items’ - or direct me to a tutorial?
(Im still learning the terms of what UE4 calls its temporary DTs - Struct? And how to load a static DT, then load a dynamic Struct to override a few default values of the DT - then output that combination as a What variable?)
- Yes, I did end up abandoning DT code. I realized it was never good to store any dynamic data in a DataTable in the first place (those are for looking up data, not for editing them)
- I don’t really remember well, but I guess I made an FStruct that had a pointer to the DataTable inside a savegame object and saved my progress there. But if you’re trying to save DataTables, I think it’s better to revise your structure so that you don’t need to do that in the first place.