Hello! I’m facing the problem of having to save a lot of information inside a single datastore key(my use case is similar to that of a neighborhood where each user has his own house but all the houses must load when a random user joins the server, but much simpler). One of the very effective methods of data compression I have found so far is converting numbers to base93(datastores support 128 characters from 0 to 127, the not control character ones are 95 and I use 2 for splitting information so 93). Anyways what I’m facing as an obstacle currently is saving Enums without having to save the entire "Enum.Category.SomeEnum
" thing in the data store.
One of the methods I thought of is to save the Enum.Category.SomeEnum.Value
property to the data store, which is an integer representing the enum(the integer is like a global enum integer, not the index of the enum for that specific category so it can have a value like 1234 instead of for example 12), however, I’m not sure if that int value is a constant and can’t be changed over time if enums are removed or added to the Roblox engine. Also regarding this method, I also don’t know how to reverse the process(basically get the Enum.Category.SomeEnum
from the integer) without having to iterate through all the enums which is extremely inefficient.
Another method I have thought of is saving the index of the Enum for that specific subcategory(basically the table.find(Enum.Category:GetEnumItems(), Enum.Category.SomeEnum)
), however, I consider this even more vulnerable regarding the issue pointed above(of Roblox adding or removing Enums).
So what I’m looking for? I’m looking for efficient ways of saving Enums that take a small number of bytes and won’t result in wrong data being loaded if Roblox makes any changes to Enums and also a function that gets the enum from its global id(.Value
) and also doesn’t on iterating over a bunch of enums. I’m looking for professional answers because I consider this an important scripting issue regarding the compression of large amounts of data that many devs may have faced, are facing, or will face in the future.