local DataStore2 = require(script.DataStore2)
local DataFolder = {
Key = "DataFolder!",
ID = 06743422368000989898000999299999999,
_DATA_FOLDER = {
Key = "DATA_TEMPLATE",
Test = {One=6,Two=8,Three=9,Four=0, yes99=false},
Catalog = {
AA = {"Yes", "lol", 9},
BB = false,
["yes"] = 9,
},
},
}
DataStore2.Combine("DATAFOLDER_KEY" .. 1, DataFolder.Key, DataFolder._DATA_FOLDER.Key) --key, item, item
local TemplateStore = DataStore2(DataFolder._DATA_FOLDER.Key, DataFolder.ID):Get(nil) --WE MUST BE ABLE TO GET A TEMPLATE.
if TemplateStore ~= nil then
print(DataStore2(DataFolder._DATA_FOLDER.Key, DataFolder.ID):Get())
else
warn("[ Data2 ]: No previous data for: " .. DataFolder._DATA_FOLDER.Key .. ".")
--
DataStore2(DataFolder._DATA_FOLDER.Key, DataFolder.ID):Set(DataFolder._DATA_FOLDER)
DataStore2(DataFolder._DATA_FOLDER.Key, DataFolder.ID):SetBackup(9, DataFolder._DATA_FOLDER)
DataStore2(DataFolder._DATA_FOLDER.Key, DataFolder.ID):Save(DataFolder._DATA_FOLDER)
warn("[ Data 2 ]: New save has been created.")
--]]
end
DataStore2:
--Public functions
function DataStore:Get(defaultValue, dontAttemptGet)
if dontAttemptGet then
return self.value
end
local backupCount = 0
if not self.haveValue then
while not self.haveValue do
task.wait(math.random(0,2)) --EDITED BY BILLY.
local success, error = self:_GetRaw():await()
--DONT LOAD ON PURPOSE SO THAAT THE SCRIPT CAN GEET THE BACKUP DATA BELLOW.
--[ EDITED BY BILLYBOBTYJOSEPH
print("l", self.backupRetries, self, DataStore)
success = nil
self.haveValue = nil
--]]
if not success then
--GEET THE FREAKING BACK UP SAVE?!
if self.backupRetries then
--self.backupretries = nil????
backupCount = backupCount + 1
if backupCount >= self.backupRetries then
self.backup = true
self.haveValue = true
self.value = self.backupValue
warn("[ DataStore2 ]: Back-up save has been activated for: " .. self.Name)
break;
end
end
self:Debug("Get returned error:", error)
end
end
if self.value ~= nil then
for _,modifier in pairs(self.beforeInitialGet) do
self.value = modifier(self.value, self)
end
end
end
local value
if self.value == nil and defaultValue ~= nil then --not using "not" because false is a possible value
value = defaultValue
else
value = self.value
end
--print(value, " LOADEDEDED") --EDITED BY BILLY
value = clone(value)
self.value = value
return value
end
DAATASTORE2w.rbxl (57.9 KB)