Asset preloader, some stuff on the client loads while functioning (bad)

This commit is contained in:
2023-12-29 03:28:45 -05:00
parent 5639dbbc53
commit c5a69b0800

View File

@@ -0,0 +1,33 @@
local Preloader = {
Assets = {},
AssetsCache = {}
}
local ContentProvider = game:GetService("ContentProvider")
function Preloader.Add(Asset)
table.insert(Preloader.Assets, Asset)
end
function Preloader:Start()
local function Callback(assetId, assetFetchStatus)
print(assetId, assetFetchStatus)
--proper switch statements would be cool, 12/28/23
if assetFetchStatus == Enum.AssetFetchStatus.Success then
table.insert(self.AssetsCache, assetId)
end
end
local Load, err = pcall(ContentProvider.PreloadAsync, ContentProvider, self.Assets, Callback)
if not Load then
warn("ContentProvider: ", err)
end
end
function Preloader:WipeTracking() --security
table.clear(self.Assets)
table.clear(self.AssetsCache)
end
return Preloader