I am making a function that packs folder data into a dictionary table so that I can use it in datastores.
I want to achieve the same format, but without the [“1”]s in it, since they hold no importance to the unpackaging program I am going to write and would only take up time.
["DataStorage"] = ▼ {
[1] = ▼ {
["Achievements"] = ▼ {
[1] = ▼ {
["ClearAGate"] = ▶ {...},
["FinishTheTutorial"] = ▶ {...},
["JoinTheGame"] = ▶ {...},
Here is the code I am using to package it.
local function PackageData(file)
local data = {};
for _, child in pairs (file:GetChildren()) do
if (child.ClassName == "Folder") then
data[child.Name] = {PackageData(child)};
else -- value class
data[child.Name] = child.Value;
end
end--]]
return data;
end
function PlayerData:GetDataPackage()
local DataPackage = PackageData(self.DataStructure);
return DataPackage;
end
I tried making a dictionary before calling the function for the first time in “GetDataPackage”, but when I do that it doesn’t read the data in the same way. If anyone has some insight into a solution then I’d appreciate it!