Conceptualizing a save state architecture

I’ve never worked with save states before, so I’m trying to evaluate the ways I could go about implementing it into a datastore system. I wasn’t able to find any other threads or direct resources that address this, so I’m looking for a few pointers on the theory behind save states from some who have gone more in-depth with data saving.

I already have a rudimentary inventory saving architecture planned out for the more direct data associated with each save state:

The only process I can think of at the moment is nesting tables for each save state, which I could see being a problem for the rest of the data accessing process as I’m afraid that may make things more difficult to manage when accessing the data. If anyone knows of any more practical theories behind a save state architecture similar to the type I’m trying to implement (typical 3-slot system with optional developer products to increase slots to a certain maximum) I would love to hear it. Thanks!

Generally I store my data in keyed table form.

Example with your inventory system:

local save = {} -- Related to a specific player
save.Abilities = {}
save.Accessories = {}

-- Example data:
save.Abilities[4] = true -- #save.Abilities = 1
save.Accessories[2] = true -- #save.Accessories = 1

When I am storing data related to the player or their ability to store items I could do this:

save.MaxAccessories = 3
save.MaxAbilities = 3

When writing and saving to somewhere (e.g. datastores) I generally will write a custom binary format of some kind for maximum storage efficiency (You could even use some compression tools such as the one here but keep in mind it will probably work better with JSON or some other plain text format: Text compression)

For simplicity you can just store JSON using HttpService:JSONEncode().

2 Likes

After talking with some others about it, it looks like keys are definitely the way to go—I was planning to expand on what I had already implemented using DataStore2 thus far but I’ll switch back for the ease of access keying the save states will give me. Thanks!